pgdb

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenConn

func OpenConn(cfg Config) (*pgx.Conn, error)

func OpenPool

func OpenPool(cfg Config, logger zerolog.Logger) (*pgxpool.Pool, error)

func Query

func Query[T any](ctx context.Context, db Seeker, query string, args ...any) ([]T, error)

func QueryStruct

func QueryStruct[T any](ctx context.Context, db Seeker, query string, args ...any) ([]T, error)

func ToSQLX

func ToSQLX(pool *pgxpool.Pool) *sqlx.DB

Types

type Config

type Config struct {
	Host        string `validate:"required"`
	User        string `validate:"required"`
	Password    string `validate:"required"`
	DBName      string `validate:"required"`
	SSLMode     string `validate:"required"`
	Socks5Proxy string
	Pool        PoolConfig
	Port        uint16 `validate:"required"`
	LogQuery    bool
}

func ConfigFromEnv

func ConfigFromEnv() (Config, error)

func (Config) URL

func (c Config) URL() string

type PoolConfig

type PoolConfig struct {
	MaxConns          int32 `validate:"required,min=1"`
	MinConns          int32 `validate:"required,min=1"`
	MaxConnLifetimeMS int
	MaxConnIdleTimeMS int
}

type Primitive

type Primitive interface {
	constraints.Ordered | uuid.UUID | decimal.Decimal | decimal.NullDecimal
}

type Seeker

type Seeker interface {
	Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
}

Jump to

Keyboard shortcuts

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