Versions in this module Expand all Collapse all v1 v1.0.1 May 15, 2026 v1.0.0 May 15, 2026 Changes in this version + var ErrEmptyRows = errors.New("db: batch rows must not be empty") + var ErrNoRows = errors.New("db: no rows found") + func AcquireAdvisoryLock(ctx context.Context, tx Tx, key int64) error + func InsertInto[T any](ctx context.Context, c *Client, b *qb.Builder, data map[string]any) (*T, error) + func IsCheckViolation(err error) bool + func IsConnectionException(err error) bool + func IsDeadlock(err error) bool + func IsForeignKeyViolation(err error) bool + func IsInvalidTextRepresentation(err error) bool + func IsNoRows(err error) bool + func IsNotNullViolation(err error) bool + func IsSerializationFailure(err error) bool + func IsUndefinedTable(err error) bool + func IsUniqueViolation(err error) bool + func PgError(err error) (*pgconn.PgError, bool) + func QueryInto[T any](ctx context.Context, c *Client, b *qb.Builder) ([]T, error) + func QueryOneInto[T any](ctx context.Context, c *Client, b *qb.Builder) (*T, error) + func ScanUUID(row pgx.Row) (uuid.UUID, error) + func TryAdvisoryLock(ctx context.Context, tx Tx, key int64) (bool, error) + func TxInsertInto[T any](ctx context.Context, tx pgx.Tx, b *qb.Builder, data map[string]any) (*T, error) + func TxQueryInto[T any](ctx context.Context, tx pgx.Tx, b *qb.Builder) ([]T, error) + func TxQueryOneInto[T any](ctx context.Context, tx pgx.Tx, b *qb.Builder) (*T, error) + func TxUpdateInto[T any](ctx context.Context, tx pgx.Tx, b *qb.Builder, data map[string]any) (*T, error) + func UpdateInto[T any](ctx context.Context, c *Client, b *qb.Builder, data map[string]any) (*T, error) + type Batch struct + func NewBatch() *Batch + func (b *Batch) Add(sql string, args ...any) *Batch + func (b *Batch) AddDelete(builder *qb.Builder) *Batch + func (b *Batch) AddExec(sql string, args ...any) *Batch + func (b *Batch) AddInsert(builder *qb.Builder, data map[string]any) *Batch + func (b *Batch) AddSelect(builder *qb.Builder) *Batch + func (b *Batch) AddUpdate(builder *qb.Builder, data map[string]any) *Batch + func (b *Batch) Len() int + type Client struct + func New(ctx context.Context, cfg Config, pools ...NamedPool) (*Client, error) + func (c *Client) Close() + func (c *Client) Delete(ctx context.Context, b *qb.Builder) (int64, error) + func (c *Client) ExecPoolSQL(ctx context.Context, poolName string, sql string, args ...any) (int64, error) + func (c *Client) ExecSQL(ctx context.Context, sql string, args ...any) (int64, error) + func (c *Client) HealthCheck(ctx context.Context) error + func (c *Client) Insert(ctx context.Context, b *qb.Builder, data map[string]any) (uuid.UUID, error) + func (c *Client) InsertBatch(ctx context.Context, b *qb.Builder, rows []map[string]any) (uuid.UUID, error) + func (c *Client) Listen(ctx context.Context, channel string, handler func(Notification) error) error + func (c *Client) ListenMulti(ctx context.Context, channels []string, handler func(Notification) error) error + func (c *Client) Notify(ctx context.Context, channel, payload string) error + func (c *Client) Pool(name string) *pgxpool.Pool + func (c *Client) QB(table string) *qb.Builder + func (c *Client) Query(ctx context.Context, b *qb.Builder) ([]map[string]any, error) + func (c *Client) QueryOne(ctx context.Context, b *qb.Builder) (map[string]any, error) + func (c *Client) QueryPool(ctx context.Context, poolName string, b *qb.Builder) ([]map[string]any, error) + func (c *Client) QuerySQL(ctx context.Context, sql string, args ...any) ([]map[string]any, error) + func (c *Client) QueryWrite(ctx context.Context, b *qb.Builder) ([]map[string]any, error) + func (c *Client) SendRead(ctx context.Context, b *Batch) ([][]map[string]any, error) + func (c *Client) SendWrite(ctx context.Context, b *Batch) ([][]map[string]any, error) + func (c *Client) Update(ctx context.Context, b *qb.Builder, data map[string]any) (int64, error) + func (c *Client) WithPoolTx(ctx context.Context, poolName string, fn func(Tx) error) error + func (c *Client) WithRetryTx(ctx context.Context, maxRetries int, fn func(Tx) error) error + func (c *Client) WithTx(ctx context.Context, fn func(Tx) error) error + func (c *Client) WithTxOpts(ctx context.Context, opts TxOptions, fn func(Tx) error) error + type Config struct + Logger *slog.Logger + QueryTimeout time.Duration + type NamedPool struct + Name string + type Notification struct + Channel string + PID uint32 + Payload string + type PoolConfig struct + ConnString string + ConnectTimeout time.Duration + ForceIPv4 bool + HealthCheckPeriod time.Duration + MaxConnIdleTime time.Duration + MaxConnLifetime time.Duration + MaxConns int32 + MinConns int32 + type Tx interface + Delete func(ctx context.Context, b *qb.Builder) (int64, error) + ExecRaw func(ctx context.Context, sql string, args ...any) (int64, error) + Insert func(ctx context.Context, b *qb.Builder, data map[string]any) (uuid.UUID, error) + QB func(table string) *qb.Builder + QueryRaw func(ctx context.Context, sql string, args ...any) ([]map[string]any, error) + ReleaseSavepoint func(ctx context.Context, name string) error + RollbackTo func(ctx context.Context, name string) error + Savepoint func(ctx context.Context, name string) error + Select func(ctx context.Context, b *qb.Builder) ([]map[string]any, error) + SelectOne func(ctx context.Context, b *qb.Builder) (map[string]any, error) + Update func(ctx context.Context, b *qb.Builder, data map[string]any) (int64, error) + type TxOptions = pgx.TxOptions