Documentation ¶
Index ¶
- Variables
- func CloseAll() error
- func CreateAnyTypeSlice(slice any) ([]any, bool)
- func Init(conf []Config) error
- func StructFields(result any) []string
- type Builder
- type Cond
- type CondBuilder
- type Config
- type DB
- func (d *DB) Before(h func(string, ...any) func())
- func (d *DB) Exec(sql string, args ...any) (sql.Result, error)
- func (d *DB) GetAll(result any, query string, args ...any) (int, error)
- func (d *DB) GetRow(result any, query string, args ...any) (int, error)
- func (d *DB) Query(sql string, args ...any) (*sql.Rows, error)
- func (d *DB) Table(table string) *builder
- func (d *DB) Transaction(fn func() error) (err error)
- type InsertBuilder
- type Manager
- type Raw
- type ReadBuilder
- type Relate
- type ResultData
- type SqlError
- type Table
- 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("条件参数错误") ErrInvalidResultPtr = errors.New("无效的结果指针") ErrEmptyTableName = errors.New("没有指定表名称") ErrDatabaseNotExists = errors.New("指定数据库不存在,或未初始化") )
Functions ¶
func CreateAnyTypeSlice ¶ added in v0.1.6
CreateAnyTypeSlice interface{}转为 []interface{}
func StructFields ¶ added in v0.5.15
Types ¶
type Builder ¶
type Builder interface { CondBuilder InsertBuilder }
type CondBuilder ¶ added in v0.2.35
type CondBuilder interface { Where(cond ...any) CondBuilder WhereMap(cond map[string]any) CondBuilder WhereRaw(cond string, args ...any) CondBuilder WhereIn(k string, in []any) CondBuilder WhereNotIn(k string, in []any) 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"` 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) 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 []string) (string, []any, error) Count() (int64, error) Fetch(fields []string, result any) (int, error) FetchRow(fields []string, result any) (int, error) FetchOne(field string) (string, error) FetchWithPage(fields []string, page int64, pageSize int64) (*ResultData, error) }
type ResultData ¶
type ResultData struct { List []map[string]any `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]any, limit ...int) (int64, error) UpdateRaw(set string, limit ...int) (int64, error) Increment(column string, amount int64, set ...map[string]any) (int64, error) Decrement(column string, amount int64, set ...map[string]any) (int64, error) Delete(limit ...int) (int64, error) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.