Documentation
¶
Index ¶
- func BeginTxOption[R any](ctx context.Context, opt *pgsql.TxOptions, ...) (*R, error)
- func Collect[T any](ctx context.Context, sql string, args ...any) ([]*T, error)
- func CollectOne[T any](ctx context.Context, sql string, args ...any) (*T, error)
- func Committed(ctx context.Context, f func(ctx context.Context))
- func Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
- func GetTx(ctx context.Context) pgx.Tx
- func IsInTx(ctx context.Context) bool
- func Iter(ctx context.Context, iter pgsql.Iterator, query string, args ...any) error
- func KeyMiddleware(key any, db DB) func(h http.Handler) http.Handler
- func Middleware(db DB) func(h http.Handler) http.Handler
- func NewContext(ctx context.Context, db DB) context.Context
- func NewKeyContext(ctx context.Context, key any, db DB) context.Context
- func Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
- func QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- func RunInReadOnlyTx(ctx context.Context, f func(ctx context.Context) error) error
- func RunInTx(ctx context.Context, f func(ctx context.Context) error) error
- func RunInTxOptions(ctx context.Context, opt *pgsql.TxOptions, f func(ctx context.Context) error) error
- func RunTx[R any](ctx context.Context, f func(ctx context.Context) (*R, error)) (*R, error)
- func With(ctx context.Context, key any) context.Context
- type DB
- type Queryer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeginTxOption ¶
func BeginTxOption[R any](ctx context.Context, opt *pgsql.TxOptions, f func(ctx context.Context) (*R, error)) (*R, error)
BeginTxOption is a shortcut function that runs f in a transaction. and returns its result.
func Middleware ¶
Middleware injects db into request's context
func NewContext ¶
NewContext creates new context
func RunInReadOnlyTx ¶
RunInReadOnlyTx calls RunInTxOptions with read only options
func RunInTxOptions ¶
func RunInTxOptions(ctx context.Context, opt *pgsql.TxOptions, f func(ctx context.Context) error) error
RunInTxOptions starts sql tx if not started
Types ¶
Click to show internal directories.
Click to hide internal directories.