Documentation
¶
Index ¶
- func AsDuplicate(err error, dup error) error
- func AsNotFound(err error, msg string) error
- func IsUniqueViolation(err error, constraint string) bool
- func TenantExec(ctx context.Context, db Beginner, id Identity, sql string, args ...any) (pgconn.CommandTag, error)
- func TenantScan(ctx context.Context, db Beginner, id Identity, sql string, args []any, ...) error
- func WithService(ctx context.Context, db Beginner, ...) error
- func WithTenant(ctx context.Context, db Beginner, id Identity, ...) error
- type Beginner
- type DB
- func (d *DB) Acquire(ctx context.Context) (*pgxpool.Conn, error)
- func (d *DB) Begin(ctx context.Context) (pgx.Tx, error)
- func (d *DB) Close()
- func (d *DB) Ping(ctx context.Context) error
- func (d *DB) Pool() *pgxpool.Pool
- func (d *DB) Read(ctx context.Context, fn func(ctx context.Context, q DBTX) error) error
- func (d *DB) Reset()
- func (d *DB) Tx(ctx context.Context) DBTX
- func (d *DB) Within(ctx context.Context, fn func(ctx context.Context) error) error
- type DBTX
- type Identity
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsDuplicate ¶
func AsNotFound ¶
func IsUniqueViolation ¶
func TenantExec ¶ added in v0.9.0
func TenantExec(ctx context.Context, db Beginner, id Identity, sql string, args ...any) (pgconn.CommandTag, error)
TenantExec runs ONE statement inside a transaction that carries the tenant GUCs, committing immediately. Multi-statement units of work belong in WithTenant. Each call costs one BEGIN/COMMIT round trip — that is the price of correct tenant scoping; do not be tempted to set session-level GUCs on a pooled connection instead (cross-tenant leak).
func TenantScan ¶ added in v0.9.0
func TenantScan(ctx context.Context, db Beginner, id Identity, sql string, args []any, dest ...any) error
TenantScan runs ONE query inside the same scoped transaction and scans a SINGLE row into dest (pgx QueryRow semantics). Deliberately NOT a rows-returning helper: streaming rows would force the transaction (and the tenant scope) to outlive the call.
func WithService ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.