postgres

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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