Versions in this module Expand all Collapse all v0 v0.0.1 Sep 2, 2020 Changes in this version + const DefaultDBAlias + var ErrMissingWhereClause = errors.New("missing WHERE clause while deleting") + var ErrRecordNotFound = errors.New("record not found") + func ConvertInSQL(sql string) string + func Expr(expr string, args ...interface{}) *clause.Expr + func GetPolicyHandler(name string) (handlerFunc interface{}, ok bool) + func IndirectType(v reflect.Type) reflect.Type + func IsChar(c rune) bool + func IsInsertSQL(sql string) bool + func IsIntZero(value reflect.Value) bool + func IsNil(val reflect.Value) bool + func MakeMapScan(rows *sqlx.Rows) (map[string]interface{}, error) + func ParseMapScan(rows *sqlx.Rows, mapValue map[string]interface{}) error + func RegisterPolicyHandler(name string, handler interface{}) + func ScanAll(rows *sqlx.Rows, dest DestWrapper) error + func SetClauseBuilder(name string, builder clause.ClauseBuilder) + type ClusterConfig struct + Driver string + Master *Config + Policy *PolicyOptions + Slaves []*Config + type Config struct + DNS string + Driver string + MaxConns int + MaxIdleConns int + MaxLifetime int + type Connection struct + type ConnectionEngine struct + Dialector dialects.Dialector + func (engine *ConnectionEngine) Master() *Connection + func (engine *ConnectionEngine) Slave() *Connection + func (engine *ConnectionEngine) Slaves() []*Connection + type DBConfig map[string]interface + type DestWrapper struct + Dest interface{} + ReflectValue reflect.Value + type EngineGroup struct + func NewDBEngineGroup(conf DBConfig, showSQL bool) (engineGroup *EngineGroup, err error) + func OpenDBEngine(conf DBConfig, showSQL bool) (*EngineGroup, error) + func OpenSingleDBEngine(conf *Config, showSQL bool) (*EngineGroup, error) + func (eg *EngineGroup) Begin() (*SqlDB, error) + func (eg *EngineGroup) BeginContext(ctx context.Context) (*SqlDB, error) + func (eg *EngineGroup) Close() + func (eg *EngineGroup) Commit() error + func (eg *EngineGroup) DriverName() string + func (eg *EngineGroup) Exec(query string, args ...interface{}) (result sql.Result, err error) + func (eg *EngineGroup) ExecContext(ctx context.Context, query string, args ...interface{}) (result sql.Result, err error) + func (eg *EngineGroup) Query(query string, args ...interface{}) (rows *sqlx.Rows, err error) + func (eg *EngineGroup) QueryContext(ctx context.Context, query string, args ...interface{}) (rows *sqlx.Rows, err error) + func (eg *EngineGroup) QueryRow(query string, args ...interface{}) (row *sqlx.Row) + func (eg *EngineGroup) QueryRowContext(ctx context.Context, query string, args ...interface{}) (row *sqlx.Row) + func (eg *EngineGroup) Raw(query string, args ...interface{}) *RawSession + func (eg *EngineGroup) RawContext(ctx context.Context, query string, args ...interface{}) *RawSession + func (eg *EngineGroup) Rebind(query string) string + func (eg *EngineGroup) Rollback() error + func (eg *EngineGroup) SetPolicy(dbAlias string, policy IPolicy) *EngineGroup + func (eg *EngineGroup) Table(table string) *Session + func (eg *EngineGroup) TableContext(ctx context.Context, table string) *Session + func (eg *EngineGroup) Tx(fn func(db *SqlDB) error) (err error) + func (eg *EngineGroup) TxContext(ctx context.Context, fn func(db *SqlDB) error) (err error) + func (eg *EngineGroup) Use(dbAlias ...string) *SqlDB + type ExecResult struct + type IPolicy interface + Slave func(engine *ConnectionEngine) *Connection + type ISqlx interface + DriverName func() string + Exec func(query string, args ...interface{}) (sql.Result, error) + ExecContext func(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + QueryRowx func(query string, args ...interface{}) *sqlx.Row + QueryRowxContext func(ctx context.Context, query string, args ...interface{}) *sqlx.Row + Queryx func(query string, args ...interface{}) (*sqlx.Rows, error) + QueryxContext func(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) + Rebind func(query string) string + type PolicyHandler func(engine *ConnectionEngine) *Connection + func LeastConnPolicy() PolicyHandler + func RandomPolicy() PolicyHandler + func RoundRobinPolicy() PolicyHandler + func WeightRandomPolicy(params PolicyParams) PolicyHandler + func WeightRoundRobinPolicy(params PolicyParams) PolicyHandler + func (handler PolicyHandler) Slave(engine *ConnectionEngine) *Connection + type PolicyOptions struct + Mode string + Params interface{} + type PolicyParams struct + Weights []int + type RawSession struct + func (raw *RawSession) Exec() (result sql.Result, err error) + func (raw *RawSession) Fetch(dest interface{}) error + func (raw *RawSession) Master() *RawSession + func (raw *RawSession) Query() (rows *sqlx.Rows, err error) + func (raw *RawSession) QueryRow() (row *sqlx.Row) + type ReflectMapper struct + func NewReflectMapper(tagName string) *ReflectMapper + func NewReflectMapperFunc(tagName string, f func(string) string) *ReflectMapper + func (r *ReflectMapper) FieldByName(v reflect.Value, name string) reflect.Value + func (r *ReflectMapper) FieldMap(v reflect.Value) map[string]reflect.Value + type Session struct + Error error + func NewSession(ctx context.Context, db *SqlDB, table string) *Session + func (session *Session) AddClause(conds ...clause.Expression) *Session + func (session *Session) AddError(err error) + func (session *Session) Asc(columns ...string) *Session + func (session *Session) BulkCreate(data interface{}) (lastInsertIdList []int64, err error) + func (session *Session) BulkUpdate(data map[string]interface{}) (affected int64, err error) + func (session *Session) Clear() + func (session *Session) Count() (count int64, err error) + func (session *Session) Create(data interface{}) (lastInsertId int64, err error) + func (session *Session) Delete() (affected int64, err error) + func (session *Session) Desc(columns ...string) *Session + func (session *Session) Distinct(columns ...string) *Session + func (session *Session) Exist() (bool, error) + func (session *Session) Find(dest interface{}) error + func (session *Session) First(dest interface{}) error + func (session *Session) GroupBy(name string) *Session + func (session *Session) Having(query interface{}, args ...interface{}) *Session + func (session *Session) Hint(query string) *Session + func (session *Session) Join(condition string, args ...interface{}) *Session + func (session *Session) Limit(limit int) *Session + func (session *Session) Master() *Session + func (session *Session) Not(query interface{}, args ...interface{}) *Session + func (session *Session) Offset(offset int) *Session + func (session *Session) Or(query interface{}, args ...interface{}) *Session + func (session *Session) OrderBy(order string) *Session + func (session *Session) Query() (*sqlx.Rows, error) + func (session *Session) QueryRow() *sqlx.Row + func (session *Session) Select(columns ...string) *Session + func (session *Session) SelectExpr(query string, args ...interface{}) *Session + func (session *Session) Update(column string, value interface{}) (affected int64, err error) + func (session *Session) Where(query interface{}, args ...interface{}) *Session + type SqlDB struct + func NewSqlDB(engine *ConnectionEngine, logging bool) *SqlDB + func (db *SqlDB) Begin() (*SqlDB, error) + func (db *SqlDB) BeginContext(ctx context.Context) (*SqlDB, error) + func (db *SqlDB) Commit() error + func (db *SqlDB) DriverName() string + func (db *SqlDB) Exec(query string, args ...interface{}) (result sql.Result, err error) + func (db *SqlDB) ExecContext(ctx context.Context, query string, args ...interface{}) (result sql.Result, err error) + func (db *SqlDB) Query(query string, args ...interface{}) (rows *sqlx.Rows, err error) + func (db *SqlDB) QueryContext(ctx context.Context, query string, args ...interface{}) (rows *sqlx.Rows, err error) + func (db *SqlDB) QueryRow(query string, args ...interface{}) (row *sqlx.Row) + func (db *SqlDB) QueryRowContext(ctx context.Context, query string, args ...interface{}) (row *sqlx.Row) + func (db *SqlDB) Raw(query string, args ...interface{}) *RawSession + func (db *SqlDB) RawContext(ctx context.Context, query string, args ...interface{}) *RawSession + func (db *SqlDB) Rebind(query string) string + func (db *SqlDB) Rollback() error + func (db *SqlDB) Table(table string) *Session + func (db *SqlDB) TableContext(ctx context.Context, table string) *Session + func (db *SqlDB) Tx(fn func(db *SqlDB) error) (err error) + func (db *SqlDB) TxContext(ctx context.Context, fn func(db *SqlDB) error) (err error) + type Statement struct + Clauses map[string]clause.Clause + Dialector dialects.Dialector + Hint string + NamedVars []sql.NamedArg + SQL strings.Builder + SQLVars []interface{} + Tables []clause.Table + func (stmt *Statement) AddClause(v clause.IClause) + func (stmt *Statement) AddClauseIfNotExists(v clause.IClause) + func (stmt *Statement) AddSQLVar(writer clause.Writer, vars ...interface{}) + func (stmt *Statement) Build(clauses ...string) + func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) (conditions []clause.Expression, err error) + func (stmt *Statement) ReInit() + func (stmt *Statement) WriteByte(c byte) error + func (stmt *Statement) WriteQuoted(value interface{}) error + func (stmt *Statement) WriteString(str string) (int, error) + func (stmt Statement) Quote(field interface{}) string + func (stmt Statement) QuoteTo(writer clause.Writer, field interface{}) + type StatementModifier interface + ModifyStatement func(*Statement)