pg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 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) JSON added in v0.0.7

func (_ DB) JSON(value any) (any, error)

Exists for our test factory which are designed to work with different databases For PG, the driver automatically handles JSON encoding.

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 {
	Migrate Migrate
	Version uint16
}

type Row

type Row = pgx.Row

Jump to

Keyboard shortcuts

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