Documentation
¶
Index ¶
- Variables
- type Clause
- type Option
- func CrossJoin(table string) Option
- func Distinct(columns ...string) Option
- func FullJoin(table, on string) Option
- func GroupBy(columns ...string) Option
- func Having(query string, binds ...any) Option
- func Join(table, on string) Option
- func LeftJoin(table, on string) Option
- func Limit(n int) Option
- func Offset(n int) Option
- func OrderBy(columns ...string) Option
- func Returning(columns ...string) Option
- func RightJoin(table, on string) Option
- func Select(columns ...string) Option
- func Table(name string) Option
- func Union(ws ...Wrapper) Option
- func UnionAll(ws ...Wrapper) Option
- func Where(query string, binds ...any) Option
- func WhereIn(query string, binds ...any) Option
- type SQLBuilder
- type TXBuilder
- type Wrapper
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrSQLDataType 不合法的插入或更新数据类型错误 ErrSQLDataType = errors.New("invaild data type, expects: struct, *struct, map[string]any") // ErrSQLBatchDataType 不合法的批量插入数据类型错误 ErrSQLBatchDataType = errors.New("invaild data type, expects: []struct, []*struct, []map[string]any") )
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(w *wrapper)
Option SQL查询选项
type SQLBuilder ¶
type SQLBuilder interface {
TXBuilder
// Transaction 启用事务
Transaction(ctx context.Context, f func(ctx context.Context, tx TXBuilder) error) error
}
SQLBuilder SQL构造器
type TXBuilder ¶
type TXBuilder interface {
// Wrap 包装查询选项
Wrap(opts ...Option) Wrapper
// contains filtered or unexported methods
}
TXBuilder 事务构造器
type Wrapper ¶
type Wrapper interface {
// One 查询一条数据
One(ctx context.Context, data any) error
// All 查询多条数据
All(ctx context.Context, data any) error
// Insert 插入数据 (数据类型:`struct`, `*struct`, `map[string]any`)
Insert(ctx context.Context, data any) (sql.Result, error)
// BatchInsert 批量插入数据 (数据类型:`[]struct`, `[]*struct`, `[]map[string]any`)
BatchInsert(ctx context.Context, data any) (sql.Result, error)
// Update 更新数据 (数据类型:`struct`, `*struct`, `map[string]any`)
Update(ctx context.Context, data any) (sql.Result, error)
// Delete 删除数据
Delete(ctx context.Context) (sql.Result, error)
// Truncate 清空表
Truncate(ctx context.Context) (sql.Result, error)
}
Wrapper SQL包装器
Click to show internal directories.
Click to hide internal directories.