db

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: AGPL-3.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, dsn string, attempts int32) (*pgxpool.Pool, error)

Currently only postgres is supported, as we try to stick to YAGNI and convetion over configuration.

func CreateDsn

func CreateDsn(dsn *cfg.DBConfig) string

func DBTearDown added in v0.7.0

func DBTearDown(conf *cfg.Config) error

DBTearDown is a helper function to clean up the test database

func InitDB

func InitDB(conf *cfg.DBConfig, log *zerolog.Logger) error

func IsNotNull added in v0.8.0

func IsNotNull(value interface{}) bool

IsNotNull returns true if a value is not "nullish" falsity is not considered nullish

func Migrate

func Migrate(ctx context.Context, log *zerolog.Logger, conf *cfg.Config, paths ...string) error

Migrate runs the migrations located in the migrations folder paths is a variadic argument, meaning that if no specific path(s) are provided, the program will try to run all of them Otherwise the arguments to path should only include the containing directory name for each migration, e.g. "000001-fix-missing-timestamps"

func Sanitize added in v0.7.2

func Sanitize(s []string) []string

func SerialParametrizedUnaryTx added in v0.9.19

func SerialParametrizedUnaryTx(
	ctx context.Context,
	conn *pgxpool.Pool,
	qName, sql string,
	errorInput any,
	params ...any,
) error

like SerializableParametrizedTx, but doesn't scan into anything, instead simply returning an error

func SerializableParametrizedTx added in v0.9.19

func SerializableParametrizedTx[T any](
	ctx context.Context,
	conn *pgxpool.Pool,
	qName, sql string,
	errorHandlerInput any,
	params ...any) (dest []T, err error)

func TxErr added in v0.9.19

func TxErr(action string, input interface{}, err error) error

Types

type Connection added in v0.9.19

type Connection struct {
	Conn *pgxpool.Pool
}

type Connector added in v0.9.19

type Connector interface {
	Get(ctx context.Context, into any, query string, args ...any) error
}

type MaybeSeq added in v0.9.19

type MaybeSeq interface {
	any | []any
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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