Documentation ¶
Index ¶
- Variables
- func GetColumnsByModel(mapper *reflectx.Mapper, model any, omitColumns ...string) []string
- func GetColumnsByType(mapper *reflectx.Mapper, typ reflect.Type, omitColumns ...string) []string
- func GetMapperByTagName(tagName string) *reflectx.Mapper
- type Builder
- type Column
- func (c Column) EQ(val any) Column
- func (c Column) Express() string
- func (c Column) GT(val any) Column
- func (c Column) GTEQ(val any) Column
- func (c Column) HasInSQL() bool
- func (c Column) In(vals ...any) Column
- func (c Column) LT(val any) Column
- func (c Column) LTEQ(val any) Column
- func (c Column) Like(val any) Column
- func (c Column) NotEQ(val any) Column
- func (c Column) NotIn(vals ...any) Column
- func (c Column) NotLike(val any) Column
- func (c Column) Use(use bool) Column
- type Condition
- type ConditionBuilder
- type Deleter
- type Inserter
- func (ins *Inserter) Columns(columns ...string) *Inserter
- func (ins *Inserter) IsIgnoreInto(ignoreInto bool) *Inserter
- func (ins *Inserter) IsReplaceInto(replaceInto bool) *Inserter
- func (ins *Inserter) NameSQL() (string, error)
- func (ins *Inserter) OnDuplicateKeyUpdateString(updateString string) *Inserter
- func (ins *Inserter) SQL() (string, error)
- func (ins *Inserter) StructColumns(m any, tagName string, omitColumns ...string) *Inserter
- type Op
- type OrderBy
- type OrderType
- type Predicate
- type Selector
- func (s *Selector) Columns(columns ...string) *Selector
- func (s *Selector) CountSQL() (string, error)
- func (s *Selector) CountSQLArgs() (string, []any, error)
- func (s *Selector) Distinct() *Selector
- func (s *Selector) ForUpdate(isForUpdate bool) *Selector
- func (s *Selector) GroupBy(columns ...string) *Selector
- func (s *Selector) Limit(limit int64) *Selector
- func (s *Selector) Offset(offset int64) *Selector
- func (s *Selector) OrderBy(orderBy ...OrderBy) *Selector
- func (s *Selector) QueryString(queryString string) *Selector
- func (s *Selector) SQL() (string, error)
- func (s *Selector) SQLArgs() (string, []any, error)
- func (s *Selector) StructColumns(model any, tagName string, omitColumns ...string) *Selector
- func (s *Selector) Where(where ConditionBuilder) *Selector
- type SimpleCondition
- type Updater
- func (u *Updater) Columns(columns ...string) *Updater
- func (u *Updater) NameSQL() (string, error)
- func (u *Updater) SQL() (string, error)
- func (u *Updater) SQLArgs() (string, []any, error)
- func (u *Updater) Set(column string, val any) *Updater
- func (u *Updater) Where(where ConditionBuilder) *Updater
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTableNameRequire = errors.New("[sqlbuilder] tableName requires") ErrColumnsRequire = errors.New("[sqlbuilder] columns requires") ErrDeleteMissWhere = errors.New("[sqlbuilder] delete sql miss where") )
View Source
var ( OpLT = Op{Symbol: "<", Text: " < "} OpLTEQ = Op{Symbol: "<=", Text: " <= "} OpGT = Op{Symbol: ">", Text: " > "} OpGTEQ = Op{Symbol: ">=", Text: " >= "} OpEQ = Op{Symbol: "=", Text: " = "} OpNEQ = Op{Symbol: "!=", Text: " != "} OpAnd = Op{Symbol: "AND", Text: " AND "} OpOr = Op{Symbol: "OR", Text: " OR "} OpIn = Op{Symbol: "IN", Text: " IN "} OpNotIN = Op{Symbol: "NOT IN", Text: " NOT IN "} OpLike = Op{Symbol: "LIKE", Text: " LIKE "} OpNotLike = Op{Symbol: "NOT LIKE", Text: " NOT LIKE "} )
Functions ¶
func GetColumnsByModel ¶
GetColumnsByModel 解析 model 所有字段名
func GetColumnsByType ¶
GetColumnsByType 通过字段 tag 解析数据库字段
func GetMapperByTagName ¶
GetMapperByTagName 根据 tag name 返回对应 mapper
Types ¶
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition 条件构造器实现
type ConditionBuilder ¶
type ConditionBuilder interface {
// contains filtered or unexported methods
}
ConditionBuilder 条件构造器
type Deleter ¶
type Deleter struct {
// contains filtered or unexported fields
}
func (*Deleter) Where ¶
func (d *Deleter) Where(where ConditionBuilder) *Deleter
Where 条件 condition 可以通过 sqlbuilder.C() 方法创建
type Inserter ¶
type Inserter struct {
// contains filtered or unexported fields
}
func NewInserter ¶
func (*Inserter) IsIgnoreInto ¶
func (*Inserter) IsReplaceInto ¶
func (*Inserter) OnDuplicateKeyUpdateString ¶
type Selector ¶
type Selector struct { IsForUpdate bool // contains filtered or unexported fields }
func NewSelector ¶
func (*Selector) CountSQLArgs ¶
CountSQLArgs 构造 count 查询 sql 并返回对应参数
func (*Selector) QueryString ¶
QueryString 自定义select字段,sql原样输出
func (*Selector) StructColumns ¶
StructColumns 通过任意model解析出表字段 tagName 解析数据库字段的 tag-name omitColumns 排除哪些字段
func (*Selector) Where ¶
func (s *Selector) Where(where ConditionBuilder) *Selector
Where 条件 condition 可以通过 sqlbuilder.C() 方法创建
type SimpleCondition ¶
type SimpleCondition struct {
// contains filtered or unexported fields
}
SimpleCondition 简单 where 条件构造
func (*SimpleCondition) And ¶
func (c *SimpleCondition) And(express string, args ...any) *SimpleCondition
And and 语句 express where 表达式
func (*SimpleCondition) Or ¶
func (c *SimpleCondition) Or(express string, args ...any) *SimpleCondition
Or or 语句 express where 表达式
func (*SimpleCondition) Predicates ¶
func (c *SimpleCondition) Predicates() []Predicate
Source Files ¶
Click to show internal directories.
Click to hide internal directories.