Documentation ¶
Index ¶
- Variables
- func CloseAll() error
- func CreateAnyTypeSlice(slice any) ([]any, bool)
- func Init(conf []Config) error
- func StructFields(result any, except ...string) []string
- type Builder
- type CBuilder
- type Cond
- type Config
- type DB
- type Fields
- type Manager
- type RBuilder
- type Relate
- type ResultData
- type SqlError
- type Table
- type Tx
- func (d *Tx) Before(h func(string, ...any) func()) *Tx
- func (d *Tx) Exec(sql string, args ...any) (sql.Result, error)
- func (d *Tx) Find(result any, query string, args ...any) (int, error)
- func (d *Tx) First(result any, query string, args ...any) (int, error)
- func (d *Tx) Query(sql string, args ...any) (*sql.Rows, error)
- func (d *Tx) Table(table string) *builder
- type UDBuilder
- type WhereBuilder
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 { BeforeHook(h func(string, ...any) func()) Builder WhereBuilder CBuilder }
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 RBuilder ¶ added in v0.6.0
type RBuilder interface { QueryString() (string, []any, error) Count() (int64, error) Find(result any) (int, error) First(result any) (int, error) One(field string) (string, error) FetchWithPage(page int64, pageSize int64) (*ResultData, error) }
RBuilder read builder (R)
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 Tx ¶ added in v0.6.0
type Tx struct {
// contains filtered or unexported fields
}
type UDBuilder ¶ added in v0.6.0
type UDBuilder 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) }
UDBuilder update or delete builder (UD)
type WhereBuilder ¶ added in v0.6.0
type WhereBuilder interface { Where(cond ...any) WhereBuilder WhereMap(cond map[string]any) WhereBuilder WhereRaw(cond string, args ...any) WhereBuilder WhereIn(k string, in []any) WhereBuilder WhereNotIn(k string, in []any) WhereBuilder ClearCond() WhereBuilder GroupBy(ks ...string) WhereBuilder OrderBy(k string, direct string) WhereBuilder Offset(offset int64) WhereBuilder Limit(limit int64) WhereBuilder Select(fields ...string) WhereBuilder RBuilder UDBuilder }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.