Documentation
¶
Index ¶
- func FromPgUUID(v pgtype.UUID) uuid.UUID
- func TextOrNull(s string) pgtype.Text
- func TimestampOrNull(t time.Time) pgtype.Timestamptz
- func ToPgUUID(id uuid.UUID) pgtype.UUID
- func WithTransaction(ctx context.Context, db Database, fn func(Transaction) error) error
- type DBTX
- type Database
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TextOrNull ¶ added in v1.10.0
TextOrNull returns a NULL pgtype.Text for an empty string, or a valid one otherwise.
func TimestampOrNull ¶ added in v1.10.0
func TimestampOrNull(t time.Time) pgtype.Timestamptz
TimestampOrNull returns a NULL pgtype.Timestamptz for the zero time, or a valid one otherwise.
func WithTransaction ¶ added in v1.10.0
WithTransaction runs fn within a database transaction, committing if fn returns nil and rolling back otherwise.
Types ¶
type DBTX ¶ added in v1.14.0
type DBTX interface {
Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, query string, args ...any) pgx.Row
Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
}
DBTX is the read-capable subset shared by Database and Transaction; it mirrors sqlc's generated DBTX, so sqlcgen.New accepts either. Components accept it so a read can run on the pool directly, while a write takes a Transaction (a superset).
Click to show internal directories.
Click to hide internal directories.