Versions in this module Expand all Collapse all v1 v1.0.1 Sep 20, 2026 v1.0.0 Sep 16, 2026 Changes in this version + const DriverTypePostgres + func CloseAll() error + func CloseCluster(clusterName string) error + func ConvertQueryAndNamedParams(query string, params ...map[string]any) (string, []any) + func DeleteByPrimaryKey(dbctx *DBContext, tableName, pkColumn string, pkValue any) (int64, error) + func DeleteByPrimaryKeyContext(ctx context.Context, dbctx *DBContext, tableName, pkColumn string, pkValue any) (int64, error) + func ExecuteReadQuery(dbctx *DBContext, queryInput ReadQueryInput) ([]map[string]any, error) + func ExecuteReadQueryContext(ctx context.Context, dbctx *DBContext, queryInput ReadQueryInput) ([]map[string]any, error) + func ExecuteWriteQuery(dbctx *DBContext, query string, params []any) (int64, int64, error) + func ExecuteWriteQueryContext(ctx context.Context, dbctx *DBContext, query string, params []any) (int64, int64, error) + func GetParameterizedInClause[T any](columnName string, columnValueArray []T) (string, map[string]any) + func HashKey(query string, args map[string]any) (string, error) + func InsertFromMap(dbctx *DBContext, tableName string, data map[string]any) (int64, int64, error) + func InsertFromMapContext(ctx context.Context, dbctx *DBContext, tableName string, data map[string]any) (int64, int64, error) + func InsertFromStruct(dbctx *DBContext, tableName string, data any) (int64, int64, error) + func InsertFromStructContext(ctx context.Context, dbctx *DBContext, tableName string, data any) (int64, int64, error) + func MultiInsertFromStructsArrayContext[T any](ctx context.Context, dbctx *DBContext, tableName string, data []T) (int64, error) + func MultiInsertFromStructsArray[T any](dbctx *DBContext, tableName string, data []T) (int64, error) + func SetConnectionConfig(clusterName string, config *ConnectionConfig) + func SetConnectionConfigE(clusterName string, config *ConnectionConfig) error + func SoftDeleteByPrimaryKey(dbctx *DBContext, tableName, deleteCol, pkCol string, value any) (int64, error) + func SoftDeleteByPrimaryKeyContext(ctx context.Context, dbctx *DBContext, tableName, deleteCol, pkCol string, ...) (int64, error) + func UpdateFromMap(dbctx *DBContext, tableName string, data map[string]any, whereClause string, ...) (int64, error) + func UpdateFromMapContext(ctx context.Context, dbctx *DBContext, tableName string, data map[string]any, ...) (int64, error) + type ConnectionConfig struct + ConnMaxIdleTime time.Duration + ConnMaxLifetime time.Duration + ConnectTimeout time.Duration + DbName string + DefaultQueryTimeout time.Duration + Host string + MaxIdleConn int + MaxOpenConn int + Password string + PgBouncer PgBouncerMode + PingTimeout time.Duration + Port string + RuntimeParams map[string]string + SSLMode string + UserName string + func (c *ConnectionConfig) Validate() error + type DBContext struct + Cluster string + Conn PostgresDbInterface + DefaultTimeout time.Duration + ExecFn func(ctx context.Context, query string, args ...any) (sql.Result, error) + PrepareFn func(ctx context.Context, query string) (*sql.Stmt, error) + QueryFn func(ctx context.Context, query string, args ...any) (*sql.Rows, error) + Tx Tx + func (ctx *DBContext) Exec(query string, args ...any) (sql.Result, error) + func (ctx *DBContext) ExecContext(c context.Context, query string, args ...any) (sql.Result, error) + func (ctx *DBContext) Prepare(query string) (*sql.Stmt, error) + func (ctx *DBContext) PrepareContext(c context.Context, query string) (*sql.Stmt, error) + func (ctx *DBContext) Query(query string, args ...any) (*sql.Rows, error) + func (ctx *DBContext) QueryContext(c context.Context, query string, args ...any) (*sql.Rows, error) + type PgBouncerMode string + const PgBouncerNone + const PgBouncerSession + const PgBouncerStatement + const PgBouncerTransaction + type PostgresDb struct + DB *sql.DB + func (pdb *PostgresDb) Begin() (*sql.Tx, error) + func (pdb *PostgresDb) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) + func (pdb *PostgresDb) Close() error + func (pdb *PostgresDb) Exec(query string, args ...any) (sql.Result, error) + func (pdb *PostgresDb) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) + func (pdb *PostgresDb) Ping() error + func (pdb *PostgresDb) PingContext(ctx context.Context) error + func (pdb *PostgresDb) Prepare(query string) (*sql.Stmt, error) + func (pdb *PostgresDb) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) + func (pdb *PostgresDb) Query(query string, args ...any) (*sql.Rows, error) + func (pdb *PostgresDb) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) + func (pdb *PostgresDb) QueryRow(query string, args ...any) *sql.Row + func (pdb *PostgresDb) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row + func (pdb *PostgresDb) Raw() *sql.DB + func (pdb *PostgresDb) SetConnMaxIdleTime(d time.Duration) + func (pdb *PostgresDb) SetConnMaxLifetime(d time.Duration) + func (pdb *PostgresDb) SetMaxIdleConns(n int) + func (pdb *PostgresDb) SetMaxOpenConns(n int) + func (pdb *PostgresDb) Stats() sql.DBStats + type PostgresDbConnector struct + DB *PostgresDb + func (pdbc *PostgresDbConnector) Open(driverName, dataSourceName string) (PostgresDbInterface, error) + type PostgresDbConnectorInterface interface + Open func(driverName string, dataSourceName string) (PostgresDbInterface, error) + type PostgresDbInterface interface + Begin func() (*sql.Tx, error) + BeginTx func(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) + Close func() error + Exec func(query string, args ...any) (sql.Result, error) + ExecContext func(ctx context.Context, query string, args ...any) (sql.Result, error) + Ping func() error + PingContext func(ctx context.Context) error + Prepare func(query string) (*sql.Stmt, error) + PrepareContext func(ctx context.Context, query string) (*sql.Stmt, error) + Query func(query string, args ...any) (*sql.Rows, error) + QueryContext func(ctx context.Context, query string, args ...any) (*sql.Rows, error) + QueryRow func(query string, args ...any) *sql.Row + QueryRowContext func(ctx context.Context, query string, args ...any) *sql.Row + Raw func() *sql.DB + SetConnMaxIdleTime func(d time.Duration) + SetConnMaxLifetime func(d time.Duration) + SetMaxIdleConns func(n int) + SetMaxOpenConns func(n int) + Stats func() sql.DBStats + func Connect(connector PostgresDbConnectorInterface, clusterName string) (PostgresDbInterface, error) + type ReadQueryInput struct + CapitaliseColumns bool + Params []any + Query string + type Tx interface + Exec func(query string, args ...any) (sql.Result, error) + Prepare func(query string) (*sql.Stmt, error) + Query func(query string, args ...any) (*sql.Rows, error) + type TxContext interface + ExecContext func(ctx context.Context, query string, args ...any) (sql.Result, error) + PrepareContext func(ctx context.Context, query string) (*sql.Stmt, error) + QueryContext func(ctx context.Context, query string, args ...any) (*sql.Rows, error)