Documentation
¶
Index ¶
- Variables
- func AppendRowsNonNil[T comparable, S ~[]T](slice S, rows pgx.Rows, fn pgx.RowToFunc[T]) (S, error)
- func CollectRowsNonNil[T comparable](rows pgx.Rows, fn pgx.RowToFunc[T]) ([]T, error)
- func GetTestLogger() *slog.Logger
- func WithTx(ctx context.Context, tx pgx.Tx) context.Context
- type DB
- type DbCleanup
Constants ¶
This section is empty.
Variables ¶
View Source
var TransactionKey = txKey{}
TransactionKey is the key used to store a pgx.Tx in a context.Context.
Functions ¶
func AppendRowsNonNil ¶
AppendRowsNonNil iterates through rows, calling fn for each row, and appending the results into a slice of T if the result is not nil.
This function closes the rows automatically on return.
func CollectRowsNonNil ¶
CollectRowsNonNil iterates through rows, calling fn for each row, and collecting the results into a slice of T if the result is not nil.
This function closes the rows automatically on return.
func GetTestLogger ¶
Types ¶
type DB ¶
type DB interface {
Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
Begin(ctx context.Context) (pgx.Tx, error)
}
DB is an interface that both pgx.Tx and *pgxpool.Pool satisfy. This allows our methods to work transparently with either a transaction or the pool.
Click to show internal directories.
Click to hide internal directories.