storage

package
v1.18.2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromPgUUID added in v1.11.0

func FromPgUUID(v pgtype.UUID) uuid.UUID

func TextOrNull added in v1.10.0

func TextOrNull(s string) pgtype.Text

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 ToPgUUID added in v1.11.0

func ToPgUUID(id uuid.UUID) pgtype.UUID

func WithTransaction added in v1.10.0

func WithTransaction(ctx context.Context, db Database, fn func(Transaction) error) error

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).

type Database

type Database interface {
	DBTX
	Ping(context.Context, time.Duration) error
	BeginTx(ctx context.Context) (Transaction, error)
	Close() error
}

func MustConnect

func MustConnect(ctx context.Context) Database

type Transaction

type Transaction interface {
	DBTX
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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