postgres

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UniqueViolationError is raised if the unique constraint is violated
	UniqueViolationError = pqerror.Code("23505") // 'unique_violation'
)

Variables

This section is empty.

Functions

func InitTables

func InitTables(logger *slog.Logger, db *sqlx.DB, ves ...api.Entity) error

func IsErrorCode

func IsErrorCode(err error, errcode pqerror.Code) bool

IsErrorCode a specific postgres specific error as defined by https://www.postgresql.org/docs/18/errcodes-appendix.html

func MigrateDB

func MigrateDB(log *slog.Logger, db *sqlx.DB, healthServer *health.Server) error

MigrateDB applies necessary DB Migrations.

func New

func New[E api.Entity](logger *slog.Logger, db *sqlx.DB, e E) api.Storage[E]

New creates a new Storage which uses the given database abstraction.

func NewPostgresDB

func NewPostgresDB(logger *slog.Logger, host, port, user, password, dbname, sslmode string, ves ...api.Entity) (*sqlx.DB, error)

NewPostgresStorage creates a new Storage which uses postgres.

func RunQuery

func RunQuery[E any](ctx context.Context, log *slog.Logger, db *sqlx.DB, builder squirrel.SelectBuilder, input map[string]any, resultFn func(e E) error) error

Types

type Op

type Op string

Jump to

Keyboard shortcuts

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