Documentation ¶
Index ¶
- Variables
- func CloseAll() error
- func CreateAnyTypeSlice(slice interface{}) ([]interface{}, bool)
- func Init(conf []Config) error
- type Builder
- type CondBuilder
- type Config
- type DB
- func (d *DB) Exec(query string, args ...interface{}) (sql.Result, error)
- func (d *DB) GetAll(result interface{}, query string, args ...interface{}) (int, error)
- func (d *DB) GetRow(result interface{}, query string, args ...interface{}) (int, error)
- func (d *DB) GetTablePrefix() string
- func (d *DB) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (d *DB) Table(table string) *builder
- func (d *DB) TableRaw(table string) *builder
- func (d *DB) Transaction(fn func() error) (err error)
- type InsertBuilder
- type Manager
- type Raw
- type ReadBuilder
- type ResultData
- type WriteBuilder
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrEmptyCond 防止在update、delete操作时,漏掉条件造成的严重后果 // 如果确实不需要条件,请将条件设置为 1=1 ErrEmptyCond = errors.New("条件不能为空") ErrEmptyValue = errors.New("值不能为空") ErrInvalidArguments = errors.New("参数错误") ErrInvalidCondArguments = errors.New("条件参数错误") ErrInvalidColumnsArguments = errors.New("字段名类型错误") ErrInvalidResultPtr = errors.New("无效的结果指针") ErrEmptyTableName = errors.New("没有指定表名称") ErrDatabaseNotExists = errors.New("指定数据库不存在,或未初始化") )
Functions ¶
func CreateAnyTypeSlice ¶ added in v0.1.6
func CreateAnyTypeSlice(slice interface{}) ([]interface{}, bool)
CreateAnyTypeSlice interface{}转为 []interface{}
Types ¶
type Builder ¶
type Builder interface { CondBuilder InsertBuilder }
type CondBuilder ¶ added in v0.2.35
type CondBuilder interface { Where(cond ...interface{}) CondBuilder WhereMap(cond map[string]interface{}) CondBuilder WhereRaw(cond string, args ...interface{}) CondBuilder WhereIn(k string, in []interface{}) CondBuilder WhereNotIn(k string, in []interface{}) CondBuilder ClearCond() CondBuilder GroupBy(k string, ks ...string) CondBuilder OrderBy(k string, direct string) CondBuilder Offset(offset int64) CondBuilder Limit(limit int64) CondBuilder ReadBuilder WriteBuilder }
type Config ¶ added in v0.2.23
type Config struct { Name string `json:"name" toml:"name"` User string `json:"user" toml:"user"` Passwd string `json:"passwd" toml:"passwd"` Host string `json:"host" toml:"host"` Port int `json:"port" toml:"port"` DbName string `json:"dbname" toml:"dbname"` Charset string `json:"charset" toml:"charset"` Prefix string `json:"prefix" toml:"prefix"` MaxOpenConns int `json:"max_open_conns" toml:"max_open_conns"` MaxIdleConns int `json:"max_idle_conns" toml:"max_idle_conns"` ConnMaxLifetime int `json:"conn_max_lifetime" toml:"conn_max_lifetime"` }
type DB ¶ added in v0.2.23
func (*DB) GetTablePrefix ¶ added in v0.2.23
GetTablePrefix 获取表前缀
func (*DB) Transaction ¶ added in v0.2.23
Transaction 事务
type InsertBuilder ¶ added in v0.2.35
type ReadBuilder ¶ added in v0.2.23
type ReadBuilder interface { MakeQueryString(fields []interface{}) (string, []interface{}, error) Count() (int64, error) Fetch(fields []interface{}, result interface{}) (int, error) FetchRow(fields []interface{}, result interface{}) (int, error) FetchOne(field string) (string, error) FetchWithPage(fields []interface{}, page int64, pageSize int64) (*ResultData, error) }
type ResultData ¶
type ResultData struct { List []map[string]interface{} `json:"list"` Count int64 `json:"count"` PageSize int64 `json:"page_size"` Page int64 `json:"page"` PageCount int64 `json:"page_count"` Start int64 `json:"start"` Mark int64 `json:"mark"` }
ResultData 分页返回数据 - 返回结果定义
type WriteBuilder ¶ added in v0.2.23
type WriteBuilder interface { Update(set map[string]interface{}, limit ...int) (int64, error) UpdateRaw(set string, limit ...int) (int64, error) Increment(column string, amount int64, set ...map[string]interface{}) (int64, error) Decrement(column string, amount int64, set ...map[string]interface{}) (int64, error) Delete(limit ...int) (int64, error) }
Click to show internal directories.
Click to hide internal directories.