Documentation ¶
Index ¶
- Variables
- func Camel2Case(name string) string
- func If(isA bool, a, b interface{}) interface{}
- func Order(column interface{}, order OrderType) clause.OrderByColumn
- func ParseColumn(c interface{}) (col clause.Column)
- func ParseDataType(data string) interface{}
- func Select(exps ...interface{}) clause.Select
- func UpdateArithmetic(column string, value interface{}, art ArithmeticType) (m map[string]interface{})
- func WhereCompare(column interface{}, value interface{}, compare ...CompareType) clause.Expression
- func WhereIn(column interface{}, value interface{}, isNot ...bool) clause.Expression
- func WhereJsonEq(column interface{}, value interface{}, key ...string) clause.Expression
- func WhereJsonHas(column interface{}, key ...string) clause.Expression
- func WhereLike(column interface{}, value interface{}, like ...LikeType) clause.Expression
- func WhereRange(column interface{}, start interface{}, end interface{}) clause.Expression
- type Allow
- type ArithmeticType
- type COUNT
- type CompareType
- type Diary
- func (n *Diary) Error(c context.Context, sql string, a ...interface{})
- func (n *Diary) Info(c context.Context, sql string, a ...interface{})
- func (n *Diary) LastSql(position ...int) string
- func (n *Diary) LogMode(logger.LogLevel) logger.Interface
- func (n *Diary) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (n *Diary) Warn(c context.Context, sql string, a ...interface{})
- type Filtered
- type Fire
- func (d *Fire) Allow(values url.Values, allow Allow) *Fire
- func (d *Fire) Clause(exps ...clause.Expression) *Fire
- func (d *Fire) Close() (err error)
- func (d *Fire) CrudAll(model interface{}, callListData interface{}) (err error)
- func (d *Fire) CrudAllPage(model interface{}, callListData interface{}, page interface{}) (pageResult PageResult, err error)
- func (d *Fire) CrudAllPagePreloadAll(model interface{}, callListData interface{}, page interface{}) (pageResult PageResult, err error)
- func (d *Fire) CrudAllPagePreloadJoin(model interface{}, callListData interface{}, page interface{}) (pageResult PageResult, err error)
- func (d *Fire) CrudAllPreloadAll(model interface{}, callListData interface{}) (err error)
- func (d *Fire) CrudAllPreloadJoin(model interface{}, callListData interface{}) (err error)
- func (d *Fire) CrudCount(model interface{}) (count int64, err error)
- func (d *Fire) CrudCreate(model interface{}, batchSize ...int) (err error)
- func (d *Fire) CrudDelete(model interface{}) (err error)
- func (d *Fire) CrudOne(model interface{}, callData interface{}) (err error)
- func (d *Fire) CrudOnePreloadAll(model interface{}, callData interface{}) (err error)
- func (d *Fire) CrudOnePreloadJoin(model interface{}, callData interface{}) (err error)
- func (d *Fire) CrudSum(model interface{}, column string) (sum float32, err error)
- func (d *Fire) CrudUpdate(model interface{}, updates ...interface{}) (err error)
- func (d *Fire) CrudUpdateByPrimaryKey(model interface{}, updates ...interface{}) (err error)
- func (d *Fire) IsExists(model interface{}) bool
- func (d *Fire) ModelWhere(model interface{}) *Fire
- func (d *Fire) OrderByColumn(column interface{}, order OrderType) *Fire
- func (d *Fire) PreloadAll() *Fire
- func (d *Fire) PreloadJoin(model interface{}) *Fire
- type LikeType
- type M
- type OrderType
- type Page
- type PageResult
- type SUM
- type SetArithmetic
- type SinglePageResult
- type TimeFields1Model
- type TimeFields2Model
- type TimeFields3Model
- type UNNEST
Constants ¶
This section is empty.
Variables ¶
var DefaultPageSize = 5
Functions ¶
func Camel2Case ¶ added in v2.1.2
func Order ¶ added in v2.1.7
func Order(column interface{}, order OrderType) clause.OrderByColumn
func ParseColumn ¶ added in v2.1.7
func ParseDataType ¶ added in v2.1.7
func ParseDataType(data string) interface{}
func UpdateArithmetic ¶
func UpdateArithmetic(column string, value interface{}, art ArithmeticType) (m map[string]interface{})
UpdateArithmetic field = field ArithmeticType Number # field = field + 1
func WhereCompare ¶ added in v2.1.6
func WhereCompare(column interface{}, value interface{}, compare ...CompareType) clause.Expression
WhereCompare column CompareEqual ? # column = ?
func WhereIn ¶ added in v2.1.7
func WhereIn(column interface{}, value interface{}, isNot ...bool) clause.Expression
WhereIn column IN(?) column NOT IN(?)
func WhereJsonEq ¶ added in v2.1.7
func WhereJsonEq(column interface{}, value interface{}, key ...string) clause.Expression
func WhereJsonHas ¶ added in v2.1.7
func WhereJsonHas(column interface{}, key ...string) clause.Expression
func WhereLike ¶ added in v2.1.7
func WhereLike(column interface{}, value interface{}, like ...LikeType) clause.Expression
WhereLike column LIKE %?%
func WhereRange ¶ added in v2.1.7
func WhereRange(column interface{}, start interface{}, end interface{}) clause.Expression
WhereRange column >= start ANd column <= end
Types ¶
type Allow ¶
type Allow struct { // where Where Filtered Range Filtered In Filtered Like Filtered // order Sorts Filtered }
func (*Allow) AllowParams ¶
AllowParams allow params
func (*Allow) ParseColumns ¶ added in v2.1.7
type ArithmeticType ¶
type ArithmeticType string
const ( ArithmeticIncrease ArithmeticType = "+" ArithmeticReduce ArithmeticType = "-" ArithmeticMultiply ArithmeticType = "*" ArithmeticExcept ArithmeticType = "/" )
type CompareType ¶
type CompareType string
const ( CompareEq CompareType = "=" CompareNeq CompareType = "<>" CompareGte CompareType = ">=" CompareGt CompareType = ">" CompareLte CompareType = "<=" CompareLt CompareType = "<" )
type Diary ¶ added in v2.1.5
type Diary struct {
Sql []string
}
type Fire ¶ added in v2.1.0
func NewInstance ¶
func (*Fire) CrudAllPage ¶ added in v2.1.0
func (d *Fire) CrudAllPage(model interface{}, callListData interface{}, page interface{}) (pageResult PageResult, err error)
func (*Fire) CrudAllPagePreloadAll ¶ added in v2.1.0
func (d *Fire) CrudAllPagePreloadAll(model interface{}, callListData interface{}, page interface{}) (pageResult PageResult, err error)
func (*Fire) CrudAllPagePreloadJoin ¶ added in v2.1.0
func (d *Fire) CrudAllPagePreloadJoin(model interface{}, callListData interface{}, page interface{}) (pageResult PageResult, err error)
func (*Fire) CrudAllPreloadAll ¶ added in v2.1.0
func (*Fire) CrudAllPreloadJoin ¶ added in v2.1.0
func (*Fire) CrudCreate ¶ added in v2.1.0
CrudCreate model support Array,Slice,Struct every struct support tag `gormCreate` validator.Struct()
func (*Fire) CrudDelete ¶ added in v2.1.0
func (*Fire) CrudOnePreloadAll ¶ added in v2.1.0
func (*Fire) CrudOnePreloadJoin ¶ added in v2.1.0
func (*Fire) CrudUpdate ¶ added in v2.1.0
CrudUpdate updates support (M or map[string]interface{}) and struct support gorm.Db.Select() and gorm.Db.Omit() TODO: struct only update non-zero fields
func (*Fire) CrudUpdateByPrimaryKey ¶ added in v2.1.5
CrudUpdateByPrimaryKey Make sure that all primary keys are not zero when updating
func (*Fire) ModelWhere ¶ added in v2.1.5
ModelWhere
func (*Fire) OrderByColumn ¶ added in v2.1.0
func (*Fire) PreloadAll ¶ added in v2.1.0
PreloadAll TODO:Multiple SQL, gorm bonding data, so query conditions other than the main table are not supported
func (*Fire) PreloadJoin ¶ added in v2.1.0
PreloadJoin TODO:Single SQL, mysql bonding data, so the conditions of all query tables are supported. use Join you need to pay attention to performance
type Page ¶
type PageResult ¶
PageResult 分页结果 https://gorm.io/docs/scopes.html#Pagination
func (*PageResult) Init ¶
func (p *PageResult) Init(page ...interface{})
func (*PageResult) SetData ¶ added in v2.1.5
func (p *PageResult) SetData(d interface{})
type SetArithmetic ¶ added in v2.1.7
type SetArithmetic struct { Column clause.Column Type ArithmeticType Value interface{} }
SetArithmetic for set
func (SetArithmetic) Build ¶ added in v2.1.7
func (a SetArithmetic) Build(builder clause.Builder)
type SinglePageResult ¶ added in v2.1.5
type SinglePageResult struct {
Data interface{} `json:"data"`
}
SinglePageResult 单页结果
type TimeFields1Model ¶ added in v2.1.5
type TimeFields1Model struct { // 13位毫秒时间戳 CreatedAt int64 `gorm:"column:created_at;autoCreateTime:milli;type:bigint;unsigned;comment:创建时间;<-:create" json:"createdAt"` }
func (*TimeFields1Model) BeforeCreate ¶ added in v2.1.5
func (t *TimeFields1Model) BeforeCreate(tx *gorm.DB) (err error)
type TimeFields2Model ¶ added in v2.1.5
type TimeFields2Model struct { TimeFields1Model // 13位毫秒时间戳,兼容用户一秒内多次点击修改 UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime:milli;type:bigint;unsigned;comment:修改时间;<-" json:"updatedAt"` }
type TimeFields3Model ¶ added in v2.1.5
type TimeFields3Model struct { TimeFields2Model // 软删除,默认为0,删除时设置当前10位秒数时间戳 DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at;type:bigint;unsigned;comment:删除时间;<-:false" json:"deletedAt"` }