postgresql

package
v0.0.0-...-b8c116a Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoWithTries

func DoWithTries(fn func() error, attempts int, delay time.Duration) (err error)

func NewPGXPoolConnection

func NewPGXPoolConnection(poolConn *pgxpool.Conn) *pgxPoolConnection

Types

type Connection

type Connection interface {
	PGXdb
	RegisterType(ctx context.Context, typeName string) error
	Release()
}

func ExtractTx

func ExtractTx(ctx context.Context) Connection

ExtractTx extracts transaction from context

type DB

type DB interface {
	Client(ctx context.Context) PGXdb
	Acquire(ctx context.Context) (Connection, error)
	Close()
}

type DBConfig

type DBConfig struct {
	Port                  string
	Host                  string
	Name                  string
	Password              string
	Username              string
	MaxConnectionAttempts int

	AutoMigrate   bool
	MigrationsDir string
}

type Database

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

func NewClient

func NewClient(ctx context.Context, sc DBConfig) (db *Database, err error)

func (*Database) Acquire

func (db *Database) Acquire(ctx context.Context) (Connection, error)

func (*Database) Client

func (db *Database) Client(ctx context.Context) PGXdb

func (*Database) Close

func (db *Database) Close()

func (Database) CopyFrom

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

func (Database) Exec

func (db Database) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)

func (Database) ExecQueryRow

func (db Database) ExecQueryRow(ctx context.Context, query string, args ...any) pgx.Row

func (Database) Get

func (db Database) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (Database) Select

func (db Database) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*Database) WithinTransaction

func (db *Database) WithinTransaction(ctx context.Context, tFunc func(ctx context.Context) error) (err error)

type PGXdb

type PGXdb interface {
	Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Exec(ctx context.Context, query string, args ...interface{}) (pgconn.CommandTag, error)
	ExecQueryRow(ctx context.Context, query string, args ...interface{}) pgx.Row
	CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
}

PGXdb интерфейс для БД

type TBD

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

func NewTestClient

func NewTestClient(ctx context.Context, sc TestDBConfig) (db *TBD, err error)

func (TBD) Acquire

func (db TBD) Acquire(ctx context.Context) (Connection, error)

func (TBD) Client

func (db TBD) Client(ctx context.Context) PGXdb

func (TBD) Close

func (db TBD) Close()

func (TBD) CopyFrom

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

func (TBD) Exec

func (db TBD) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)

func (TBD) ExecQueryRow

func (db TBD) ExecQueryRow(ctx context.Context, query string, args ...any) pgx.Row

func (TBD) Get

func (db TBD) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (TBD) Select

func (db TBD) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (TBD) SetUp

func (db TBD) SetUp(t *testing.T)

func (TBD) TearDown

func (db TBD) TearDown()

func (TBD) Truncate

func (db TBD) Truncate(ctx context.Context)

func (TBD) WithinTransaction

func (db TBD) WithinTransaction(ctx context.Context, tFunc func(ctx context.Context) error) (err error)

type TestDBConfig

type TestDBConfig struct {
	Port         string
	Host         string
	Name         string
	Password     string
	Username     string
	MigrationDir string
}

type Transactor

type Transactor interface {
	WithinTransaction(context.Context, func(ctx context.Context) error) error
}

type Tx

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

func NewTx

func NewTx(tx pgx.Tx) *Tx

func (Tx) CopyFrom

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

func (Tx) Exec

func (t Tx) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)

func (Tx) ExecQueryRow

func (t Tx) ExecQueryRow(ctx context.Context, query string, args ...any) pgx.Row

func (Tx) Get

func (t Tx) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (Tx) RegisterType

func (t Tx) RegisterType(ctx context.Context, typeName string) error

func (Tx) Release

func (t Tx) Release()

func (Tx) Select

func (t Tx) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Jump to

Keyboard shortcuts

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