pgxpoolv5

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPingTimeout = 15 * time.Second

Variables

This section is empty.

Functions

func DefaultPoolOpener

func DefaultPoolOpener(ctx context.Context, dsn string) (*pgxpool.Pool, error)

func Query

func Query[T any](ctx context.Context, db *DB, query string,
	pointers func(*T) []interface{}, args ...any) ([]T, error)

Query is a generic query helper with context.

Types

type DB

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

func NewDB

func NewDB(dsns []string, options ...Option) (*DB, error)

func (*DB) CopyFrom

func (db *DB) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)

func (*DB) DoTx

func (db *DB) DoTx(f func(db dbx.DBxer[*pgxpool.Pool, pgx.Tx, pgx.TxOptions]) error, opts pgx.TxOptions) error

func (*DB) DoTxContext

func (db *DB) DoTxContext(
	ctx context.Context,
	f func(ctx context.Context, db dbx.DBxer[*pgxpool.Pool, pgx.Tx, pgx.TxOptions]) error,
	opts pgx.TxOptions) error

func (*DB) Exec

func (db *DB) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)

func (*DB) Prepare

func (db *DB) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)

func (*DB) Query

func (db *DB) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)

func (*DB) QueryRow

func (db *DB) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row

func (*DB) SendBatch

func (db *DB) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

func (*DB) Tx

func (db *DB) Tx() (pgx.Tx, error)

func (*DB) WithDefaultNode

func (db *DB) WithDefaultNode(criteria cluster.NodeStateCriteria) *DB

func (*DB) WithReadFromNode

func (db *DB) WithReadFromNode(criteria cluster.NodeStateCriteria) *DB

func (*DB) WithWriteToNode

func (db *DB) WithWriteToNode(criteria cluster.NodeStateCriteria) *DB

type Option

type Option func(*DB)

func WithGenericOptions

func WithGenericOptions(options ...dbx.Option[*pgxpool.Pool]) Option

func WithInitPingTimeout

func WithInitPingTimeout(timeout time.Duration) Option

func WithPoolOpener

func WithPoolOpener(poolOpener PoolOpener) Option

type PoolOpener

type PoolOpener func(ctx context.Context, dsn string) (*pgxpool.Pool, error)

Jump to

Keyboard shortcuts

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