db

package
v0.0.0-...-da226d4 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToContext

func AddToContext(ctx context.Context, conn IClient) context.Context

func ExecTx

func ExecTx(ctx context.Context, fn func(ctx context.Context) error) error

Types

type DBPool

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

func (*DBPool) Commit

func (d *DBPool) Commit(ctx context.Context) error

func (*DBPool) Rollback

func (d *DBPool) Rollback(ctx context.Context) error

type DBTx

type DBTx struct {
	pgx.Tx
}

func (DBTx) BeginTx

func (tx DBTx) BeginTx(ctx context.Context, opts pgx.TxOptions) (pgx.Tx, error)

type IClient

type IClient interface {
	BeginTx(ctx context.Context, opts pgx.TxOptions) (pgx.Tx, error)
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error

	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
}

func FromContext

func FromContext(ctx context.Context) IClient

func New

func New(ctx context.Context, host string, port int, user, password, name string, options ...Option) (IClient, error)

type Option

type Option = func(d *DBPool)

func WithLog

func WithLog() Option

func WithPoolSize

func WithPoolSize(size int) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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