Documentation
¶
Index ¶
- func Filter(slice []string, filterMap map[string]string) (result []string)
- func NewPipeline() *pipeline
- func Pairs(keyValuePairs []any) (map[string]any, error)
- func PairsHook(keyValuePairs []any, identifiers map[string]any, hook string) (map[string]any, error)
- type Exec
- type ExecResult
- type Option
- func WithConnMax(maxOpenConns int) Option
- func WithConnMaxIdleTime(maxConnIdleTime time.Duration) Option
- func WithConnMaxLifetime(maxConnLifetime time.Duration) Option
- func WithDBName(dbName string) Option
- func WithDriverName(driverName string) Option
- func WithDsn(dsn string) Option
- func WithHost(host string) Option
- func WithMaxIdleConns(maxIdleConns int) Option
- func WithMaxOpenConns(maxOpenConns int) Option
- func WithPassword(password string) Option
- func WithPort(port int) Option
- func WithSSLMode(sslMode string) Option
- func WithUser(user string) Option
- type Postgres
- type Select
- type StringSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPipeline ¶
func NewPipeline() *pipeline
NewPipeline creates a new empty pipeline instance. The pipeline can be used to chain multiple database operations that should be executed atomically in a transaction.
Types ¶
type Exec ¶
type Exec interface {
Debug() Exec
Exec(ctx context.Context) (any, error)
ExecInTx(ctx context.Context) (result *ExecResult, err error)
Insert(query string, keyValuePairs ...any) Exec
Update(query string, keyValuePairs ...any) Exec
Delete(query string, keyValuePairs ...any) Exec
Select(query string, destination any, keyValuePairs ...any) Exec
Wrap(exec Exec) Exec
FromResult(from string) string
}
type ExecResult ¶
type ExecResult struct {
// contains filtered or unexported fields
}
ExecResult is the result of an exec query.
func (*ExecResult) TxResult ¶
func (e *ExecResult) TxResult(query string) any
type Option ¶
type Option func(*config)
Option is a function that configures the postgres database.
func WithConnMax ¶
WithConnMax sets the max conn. maxOpenConns is the maximum number of open connections to the database.
func WithConnMaxIdleTime ¶
WithConnMaxIdleTime sets the max conn idle time. maxConnIdleTime is the maximum amount of time a connection may be idle.
func WithConnMaxLifetime ¶
WithConnMaxLifetime sets the max conn lifetime. maxConnLifetime is the maximum amount of time a connection may be reused.
func WithDBName ¶
WithDBName sets the db name. dbName is the name of the database to connect to.
func WithDriverName ¶
WithDriverName sets the driver name.
func WithMaxIdleConns ¶
func WithMaxOpenConns ¶
WithMaxOpenConns sets the max open conns. maxOpenConns is the maximum number of open connections to the database.
func WithPassword ¶
WithPassword sets the password. password is the password to connect with.
func WithSSLMode ¶
WithSSLMode sets the ssl mode. sslMode is the SSL mode to use.
type Postgres ¶
type Postgres interface {
Select(query string, destination any, keyValuePairs ...any) Select
Insert(query string, keyValuePairs ...any) Exec
Update(query string, keyValuePairs ...any) Exec
Delete(query string, keyValuePairs ...any) Exec
FromResult(from string) string
}
Postgres is the interface for the postgres database client.
type Select ¶
type Select interface {
Debug() Select
One(ctx context.Context) (found bool, err error)
Many(ctx context.Context) (found bool, err error)
}
Select is an interface for selecting data from the database.
type StringSlice ¶
type StringSlice []string
func (*StringSlice) Scan ¶
func (s *StringSlice) Scan(src any) error