db

package
v4.50.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: MIT Imports: 12 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoHost = errors.New("no host for database connection")

	ErrNoTransaction = errors.New("no transaction in context, please wrap with DoAtomic()")

	SQLTimeout = time.Second * 5
)

Functions

func StoreTx

func StoreTx(ctx context.Context, tx pgx.Tx) context.Context

Types

type App added in v4.14.0

type App struct {
	// contains filtered or unexported fields
}

func New

func New(config Config, tracer trace.Tracer) (App, error)

func (App) Bulk added in v4.14.0

func (a App) Bulk(ctx context.Context, fetcher func() ([]any, error), schema, table string, columns ...string) error

func (App) Close added in v4.14.1

func (a App) Close()

func (App) Create added in v4.14.0

func (a App) Create(ctx context.Context, query string, args ...any) (uint64, error)

func (App) DoAtomic added in v4.14.0

func (a App) DoAtomic(ctx context.Context, action func(context.Context) error) error

func (App) Enabled added in v4.20.0

func (a App) Enabled() bool

func (App) Exec added in v4.14.0

func (a App) Exec(ctx context.Context, query string, args ...any) error

func (App) Get added in v4.14.0

func (a App) Get(ctx context.Context, scanner func(pgx.Row) error, query string, args ...any) error

func (App) List added in v4.14.0

func (a App) List(ctx context.Context, scanner func(pgx.Rows) error, query string, args ...any) (err error)

func (App) One added in v4.26.0

func (a App) One(ctx context.Context, query string, args ...any) error

func (App) Ping added in v4.14.0

func (a App) Ping() error

type Config

type Config struct {
	// contains filtered or unexported fields
}

func Flags

func Flags(fs *flag.FlagSet, prefix string, overrides ...flags.Override) Config

type Database added in v4.24.0

type Database interface {
	Ping(context.Context) error
	Close()
	Begin(context.Context) (pgx.Tx, error)
	Query(context.Context, string, ...any) (pgx.Rows, error)
	QueryRow(context.Context, string, ...any) pgx.Row
}

Jump to

Keyboard shortcuts

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