pg

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRows         = pgx.ErrNoRows
	ErrMoreThanOneRow = errors.New("Result contained more than 1 row")
)

Functions

func GetCurrentMigrationVersion

func GetCurrentMigrationVersion(db DB, appName string) (int, error)

func MigrateAll

func MigrateAll(db DB, appName string, migrations []Migration) error

func Scalar

func Scalar[T any](db DB, sql string, args ...any) (T, error)

Types

type DB

type DB struct {
	*pgxpool.Pool
}

func New

func New(url string) (DB, error)

func (DB) IsNotFound

func (db DB) IsNotFound(err error) bool

func (DB) MustExec

func (db DB) MustExec(sql string, args ...any)

func (DB) Placeholder

func (_ DB) Placeholder(i int) string

Exists for our test factory which are designed to work with different databases

func (DB) RowToMap

func (db DB) RowToMap(sql string, args ...any) (typed.Typed, error)

func (DB) RowsToMap

func (db DB) RowsToMap(sql string, args ...any) ([]typed.Typed, error)

func (DB) TableExists

func (db DB) TableExists(tableName string) (bool, error)

func (DB) Transaction

func (db DB) Transaction(fn func(tx pgx.Tx) error) error

type Migrate

type Migrate func(tx pgx.Tx) error

type Migration

type Migration struct {
	Version uint16
	Migrate Migrate
}

type Row

type Row = pgx.Row

Jump to

Keyboard shortcuts

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