database

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(ctx context.Context, db DB, query string, args []interface{}) (sql.Result, error)

func GetTable

func GetTable(m any) string

func GetTableSingular

func GetTableSingular(m any) string

func Register

func Register(ctx context.Context, config Config, migrations Upper)

func RegisterDB

func RegisterDB(ctx context.Context, db *sqlx.DB)

func RegisterTransactions

func RegisterTransactions(ctx context.Context, mtx sync.Locker)

func Value

func Value[T any](txFunc Transaction, cb func(tx *sqlx.Tx) (T, error)) (T, error)

Types

type Config

type Config interface {
	DriverName() string
	DataSourceName() string
}

type DB

type DB interface {
	sqlx.QueryerContext
	sqlx.ExecerContext
	DriverName() string
}

type Read

type Read func(func(tx *sqlx.Tx) error) error

func NewRead

func NewRead(ctx context.Context, mtx sync.Locker, db DB) Read

func (Read) Run

func (f Read) Run(cb func(tx *sqlx.Tx) error) error

type Tabler

type Tabler interface {
	Table() string
}

type Transaction

type Transaction interface {
	Run(func(tx *sqlx.Tx) error) error
}

type Update

type Update func(func(tx *sqlx.Tx) error) error

func NewUpdate

func NewUpdate(ctx context.Context, mtx sync.Locker, db DB) Update

func (Update) Run

func (f Update) Run(cb func(tx *sqlx.Tx) error) error

type Upper

type Upper interface {
	Up(ctx context.Context, db DB) error
}

Directories

Path Synopsis
Package builder provides a fluent, chainable query builder for the database package.
Package builder provides a fluent, chainable query builder for the database package.
Package dialects defines the query ASTs that describe SQL statements and the Dialect interface that renders them into RawQueries.
Package dialects defines the query ASTs that describe SQL statements and the Dialect interface that renders them into RawQueries.
generic
Package generic provides a database-agnostic implementation of the dialects.Dialect interface.
Package generic provides a database-agnostic implementation of the dialects.Dialect interface.
mysql
Package mysql implements the dialects.Dialect interface for MySQL.
Package mysql implements the dialects.Dialect interface for MySQL.
postgres
Package postgres implements the dialects.Dialect interface for PostgreSQL.
Package postgres implements the dialects.Dialect interface for PostgreSQL.
sqlite
Package sqlite implements the dialects.Dialect interface for SQLite.
Package sqlite implements the dialects.Dialect interface for SQLite.
Package model defines the types and helpers for persisting and loading database records through Go structs called models.
Package model defines the types and helpers for persisting and loading database records through Go structs called models.
Package schema provides a dialect-agnostic DSL for describing and executing database schema changes such as creating, altering, and dropping tables.
Package schema provides a dialect-agnostic DSL for describing and executing database schema changes such as creating, altering, and dropping tables.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL