pgxhelper

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

README

Version 0.0.6

Documentation

Index

Constants

View Source
const (
	OPR_EQUAL = "="
	OPR_IN    = "IN"
	OPR_ANY   = "ANY"
	OPR_GTE   = ">="
)

Variables

View Source
var (
	ErrDuplicateKey = fmt.Errorf("DUPLICATE KEY")
	ErrNotFound     = fmt.Errorf("NOT FOUND")
)

Functions

This section is empty.

Types

type Condition

type Condition struct {
	ColumnName string
	Operator   string
	Value      any
}

type ConditionGroup

type ConditionGroup struct {
	Join       Joiner
	Conditions []*Condition
	Group      *ConditionGroup
}

type Config

type Config struct {
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
	SslMode  string
	Timezone string
}

func (Config) MakeDSN

func (c Config) MakeDSN() string

type DBConfig

type DBConfig interface {
	MakeDSN() string
}

func GetConfigFromEnv

func GetConfigFromEnv() (DBConfig, error)

func GetConfigFromEnvOption added in v0.0.5

func GetConfigFromEnvOption(keys *KeysConfig) (DBConfig, error)

type DatabaseHelper

type DatabaseHelper struct {
	Pool *pgxpool.Pool
}

func (*DatabaseHelper) BuildDynamicQuery added in v0.0.7

func (dh *DatabaseHelper) BuildDynamicQuery(values *[]any, opts []*ConditionGroup) string

func (*DatabaseHelper) Exec

func (dh *DatabaseHelper) Exec(ctx context.Context, query string, values ...any) error

func (*DatabaseHelper) Exist

func (dh *DatabaseHelper) Exist(ctx context.Context, table string, condition string, values ...any) (bool, error)

func (*DatabaseHelper) MakeTx

func (dh *DatabaseHelper) MakeTx(ctx context.Context) (pgx.Tx, func(err error) error, error)

func (*DatabaseHelper) Query

func (dh *DatabaseHelper) Query(ctx context.Context, scanner Scanner, query string, values ...any) error

type Joiner

type Joiner = string
const (
	JOINER_AND Joiner = " AND "
	JOINER_OR  Joiner = " OR "
)

type KeysConfig added in v0.0.5

type KeysConfig struct {
	Host     string
	Port     string
	User     string
	Password string
	Name     string
	SslMode  string
	Timezone string
}

type Scanner

type Scanner = func(row pgx.Row) error

Jump to

Keyboard shortcuts

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