Documentation
¶
Overview ¶
Package postgres provides a wrapper to connect to PostgreSQL. It also implements Unit of Work interface. See uow package for more info about Unit of Work.
Index ¶
- Variables
- func NewDBWithPgx(cfg Config) (*bun.DB, error)
- func NewPgxPool(cfg Config) (*pgxpool.Pool, error)
- func NewTxGetter() *trmpgx.CtxGetter
- func NewTxManager(pool *pgxpool.Pool) (*manager.Manager, error)
- type BunDB
- type BunTx
- func (t *BunTx) Begin(_ context.Context) (uow.Tx, error)
- func (t *BunTx) Commit(_ context.Context) error
- func (t *BunTx) Exec(ctx context.Context, query string, args ...interface{}) (int64, error)
- func (t *BunTx) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (t *BunTx) Rollback(_ context.Context) error
- type Config
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrAlreadyExist is returned when the new record violates unique key restriction. ErrAlreadyExist = errors.New("record already exist") // ErrNullDB is returned when nil is sent to mandatory db parameter. ErrNullDB = errors.New("db instance is null") )
Functions ¶
func NewDBWithPgx ¶
NewDBWithPgx creates a bun.DB using pgx as driver.
func NewPgxPool ¶
NewPgxPool creates a new pgx pool.
func NewTxGetter ¶
NewTxGetter creates a new transaction getter.
Types ¶
type BunDB ¶
type BunDB struct {
// contains filtered or unexported fields
}
BunDB wraps uptrace/bun to comply with internal use.
type BunTx ¶
type BunTx struct {
// contains filtered or unexported fields
}
BunTx wraps uptrace/bun tx to comply with internal use.
type Config ¶
type Config struct { Host string `env:"POSTGRES_HOST,default=localhost"` User string `env:"POSTGRES_USER,required"` Password string `env:"POSTGRES_PASSWORD,required"` Name string `env:"POSTGRES_NAME,required"` SSLMode string `env:"POSTGRES_SSL_MODE,default=disable"` Port int `env:"POSTGRES_PORT,default=5432"` }
Config holds configuration for PostgreSQL.
Click to show internal directories.
Click to hide internal directories.