postgres

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PsqlMaxParams = 65535
)

Variables

This section is empty.

Functions

func Error

func Error(message string, err error, fallback srverr.ErrCode) error

Types

type Closer

type Closer interface {
	Close() error
}

type Config

type Config struct {
	Host              string
	Port              int
	Database          string
	User              string
	Pass              string //nolint:gosec // internal config not exposed publicly
	Sslmode           string
	Options           map[string]string
	MigrationsEnabled bool
	AtlasBin          string
}

type DB

type DB struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func InitDB

func InitDB(ctx context.Context, conf, testConf Config, schema embed.FS) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) WithTx

func (db *DB) WithTx(ctx context.Context, fn func(tx DBTX) error) error

type DBTX

type DBTX interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	SelectContext(ctx context.Context, dest any, query string, args ...any) error
	GetContext(ctx context.Context, dest any, query string, args ...any) error
	NamedExecContext(ctx context.Context, query string, arg any) (sql.Result, error)
	NamedQuery(query string, arg any) (*sqlx.Rows, error)
}

type TestDB

type TestDB[D Closer] struct {
	// contains filtered or unexported fields
}

func NewServiceTestDB

func NewServiceTestDB[D Closer](
	t *testing.T,
	open func(ctx context.Context, conf, devConf Config) (D, error),
	seed func(t *testing.T, db D),
) *TestDB[D]

func (*TestDB[D]) Close

func (t *TestDB[D]) Close(ctx context.Context) error

func (*TestDB[D]) DB

func (t *TestDB[D]) DB() D

Jump to

Keyboard shortcuts

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