postgres

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(ctx context.Context, conn Conn, sql string, args ...any) error

func Query

func Query[T any](ctx context.Context, conn Conn, sql string, args ...any) ([]T, error)

func QueryRow

func QueryRow[T any](ctx context.Context, conn Conn, sql string, args ...any) (T, error)

Types

type Config

type Config struct{ URI string }

type Conn

type Conn interface {
	Begin(ctx context.Context) (pgx.Tx, error)
	Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}

type DB

type DB struct {
	*pgxpool.Pool
	// contains filtered or unexported fields
}

func NewDB

func NewDB(cfg Config) *DB

func OpenDB

func OpenDB(ctx context.Context, cfg Config) (*DB, error)

func (*DB) Close

func (db *DB) Close()

func (*DB) Open

func (db *DB) Open(ctx context.Context) error

type NamedArgs

type NamedArgs = pgx.NamedArgs

type Tx

type Tx interface {
	Conn
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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