database

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 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

Jump to

Keyboard shortcuts

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