Documentation ¶
Index ¶
- Constants
- func BuildInsertParams(m map[string]interface{}, rowIt int, params []string, values []interface{}) string
- func DropTestDB(cfg *Config) error
- func ReturningAll(query string) string
- func ReturningCustom(query string, fields []string) string
- func ReturningID(query string) string
- func SetEnvPrefix(pref string)
- func WithOptions(option []QueryOption, query string, args ...interface{}) (string, []interface{})
- type Config
- type DBX
- func (dbx *DBX) Close() error
- func (dbx *DBX) Exec(query string, args ...interface{}) (sql.Result, error)
- func (dbx *DBX) MustBegin() *Tx
- func (dbx *DBX) NamedExec(query string, arg interface{}) (sql.Result, error)
- func (dbx *DBX) NamedInsert(target interface{}, tableName string, paramNames []string, ...) (string, []interface{}, error)
- func (dbx *DBX) NamedSelect(dest interface{}, query string, arg interface{}) error
- func (dbx *DBX) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (dbx *DBX) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (dbx *DBX) Rebind(query string) string
- func (dbx *DBX) Select(dest interface{}, query string, args ...interface{}) error
- func (dbx *DBX) SetLogger(logType int8, out io.Writer) error
- func (dbx *DBX) SetLoggerAsync(async bool)
- func (dbx *DBX) SetMaxIdleConns(n int)
- func (dbx *DBX) SetMaxOpenConns(n int)
- func (dbx *DBX) SetSlowLogMin(minDur time.Duration)
- func (dbx *DBX) SkipLog()
- func (dbx *DBX) Unsafe() *DBX
- type EmptySliceErr
- type MissingParamErr
- type NilPointerErr
- type Querier
- type Querierx
- type QueryOption
- type Tx
- func (tx *Tx) Commit() error
- func (tx *Tx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (tx *Tx) NamedExec(query string, arg interface{}) (sql.Result, error)
- func (tx *Tx) NamedInsert(target interface{}, tableName string, paramNames []string, ...) (string, []interface{}, error)
- func (tx *Tx) NamedSelect(dest interface{}, query string, arg interface{}) error
- func (tx *Tx) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (tx *Tx) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (tx *Tx) Rebind(query string) string
- func (tx *Tx) Rollback() error
- func (tx *Tx) Select(dest interface{}, query string, args ...interface{}) error
- func (tx *Tx) SkipLog()
- func (tx *Tx) Unsafe() *Tx
- type WrongTypeErr
Constants ¶
View Source
const ( MysqlDriver = "mysql" PgxDriver = "pgx" PostgresDriver = "postgres" )
View Source
const ( LevelSlowQuery = "SLOW_QUERY" LevelDebug = "DEBUG" LevelError = "ERROR" )
View Source
const ( LogError = 1 << iota LogDebug LogSLow DefaultSlowLogMin = 1 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func BuildInsertParams ¶
func DropTestDB ¶
func ReturningAll ¶
func ReturningCustom ¶
func ReturningID ¶
func SetEnvPrefix ¶
func SetEnvPrefix(pref string)
func WithOptions ¶
func WithOptions(option []QueryOption, query string, args ...interface{}) (string, []interface{})
Types ¶
type Config ¶
type Config struct { Ssl bool `mapstructure:"ssl"` Driver string `mapstructure:"driver"` Host string `yaml:"host" mapstructure:"host"` Port int `mapstructure:"port"` DBName string `mapstructure:"db_name"` User string `mapstructure:"user"` Password string `mapstructure:"password"` DoLog bool LogDir string SlowQueryDuration time.Duration // contains filtered or unexported fields }
DBConfig holds the configuration parameters of main DB connection
func LoadConfigFromEnv ¶
type DBX ¶
type DBX struct {
// contains filtered or unexported fields
}
func NewTest ¶
NewTest creates an instance of *DBX especially for test Multiple checks are done to ensure we are not working on the live data Configuration can either be passed as an argument, or retrieved from the environment variables. If none were set, default values are used.
func (*DBX) NamedInsert ¶
func (*DBX) NamedSelect ¶
func (*DBX) SetLoggerAsync ¶
func (*DBX) SetMaxIdleConns ¶
func (*DBX) SetMaxOpenConns ¶
func (*DBX) SetSlowLogMin ¶
type EmptySliceErr ¶
type EmptySliceErr struct {
// contains filtered or unexported fields
}
func (*EmptySliceErr) Error ¶
func (e *EmptySliceErr) Error() string
type MissingParamErr ¶
type MissingParamErr struct {
// contains filtered or unexported fields
}
func (*MissingParamErr) Error ¶
func (e *MissingParamErr) Error() string
type NilPointerErr ¶
type NilPointerErr struct {
// contains filtered or unexported fields
}
func (*NilPointerErr) Error ¶
func (e *NilPointerErr) Error() string
type Querier ¶
type Querier interface { Queryx(query string, args ...interface{}) (*sqlx.Rows, error) QueryRowx(query string, args ...interface{}) *sqlx.Row Select(dest interface{}, query string, args ...interface{}) error Exec(query string, args ...interface{}) (sql.Result, error) NamedExec(query string, arg interface{}) (sql.Result, error) Rebind(query string) string }
type QueryOption ¶
type QueryOption struct {
// contains filtered or unexported fields
}
func NewOffsetOption ¶
func NewOffsetOption(offset int, limit int) QueryOption
func NewPageOption ¶
func NewPageOption(page int, length int) QueryOption
func (QueryOption) IncOffset ¶
func (qo QueryOption) IncOffset(inc int)
func (QueryOption) IncPage ¶
func (qo QueryOption) IncPage(inc int)
func (QueryOption) Page ¶
func (qo QueryOption) Page() int
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) NamedInsert ¶
func (*Tx) NamedSelect ¶
type WrongTypeErr ¶
type WrongTypeErr struct {
// contains filtered or unexported fields
}
func (*WrongTypeErr) Error ¶
func (e *WrongTypeErr) Error() string
Click to show internal directories.
Click to hide internal directories.