postgres

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Postgres

type Postgres struct {
	// contains filtered or unexported fields
}

Postgres wraps a Bun DB connection and error checker for Postgres-specific behavior.

func New

func New(ctx context.Context, c db.Config) (*Postgres, error)

New initializes a Postgres connection using a pgx pool and returns a helper.

func (*Postgres) BeginTx

func (p *Postgres) BeginTx(ctx context.Context) (bun.Tx, error)

BeginTx begins a new transaction with default options.

func (*Postgres) Close

func (p *Postgres) Close(ctx context.Context) error

Close closes the underlying Bun DB.

func (*Postgres) DB

func (p *Postgres) DB() *bun.DB

DB exposes the underlying Bun DB.

func (*Postgres) ErrorChecker

func (p *Postgres) ErrorChecker() db.ErrorChecker

ErrorChecker returns a Postgres error classifier.

func (*Postgres) RunInTx

func (p *Postgres) RunInTx(
	ctx context.Context,
	fn func(ctx context.Context, tx bun.Tx) error,
) error

RunInTx executes a function within a transaction.

type PostgresErrorChecker

type PostgresErrorChecker struct{}

PostgresErrorChecker classifies common Postgres errors such as no rows and unique constraint violations.

func (*PostgresErrorChecker) IsErrNoRows

func (checker *PostgresErrorChecker) IsErrNoRows(err error) bool

func (*PostgresErrorChecker) IsUniqueConstraintError

func (checker *PostgresErrorChecker) IsUniqueConstraintError(err error) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL