Documentation
¶
Index ¶
- Constants
- func AndCompose[T ComposeType](cond *Condition, column string, operator string, value []T)
- func IsNotFound(db *gorm.DB) int
- func IsValid(r interface{}) bool
- func MLike(v string) string
- func OrCompose[T ComposeType](cond *Condition, column string, operator string, value []T)
- func PLike(v string) string
- func SLike(v string) string
- type Base
- func (b *Base) Cancel()
- func (b *Base) Count(model interface{}, count *int64) error
- func (b *Base) Create(model interface{}, opts ...Option) error
- func (b *Base) Delete(model interface{}, cond IQuery) error
- func (b *Base) Find(model interface{}, where IQuery, sel ISelect) error
- func (b *Base) First(model interface{}, where IQuery, sel ISelect) error
- func (b *Base) Get(model interface{}) (result interface{}, err error)
- func (b *Base) Gets(model interface{}) (results []*interface{}, err error)
- func (b *Base) NewDB() *gorm.DB
- func (b *Base) UpdateColumn(model interface{}, where IQuery, column string, value interface{}) error
- func (b *Base) Updates(model interface{}, where IQuery, opts ...Option) error
- func (b *Base) WithOrder(order interface{}) *Base
- func (b *Base) WithResult(result interface{}) *Base
- type Column
- type ComposeType
- type Condition
- func (sq *Condition) And(column, operator string, value interface{}) *Condition
- func (sq *Condition) AndBetween(column string, value1, value2 interface{}) *Condition
- func (sq *Condition) AndEq(column string, value interface{}) *Condition
- func (sq *Condition) AndGt(column string, value interface{}) *Condition
- func (sq *Condition) AndGtEq(column string, value interface{}) *Condition
- func (sq *Condition) AndLt(column string, value interface{}) *Condition
- func (sq *Condition) AndLtEq(column string, value interface{}) *Condition
- func (sq *Condition) AndNEq(column string, value interface{}) *Condition
- func (sq *Condition) Between(column string, value1, value2 interface{}) *Condition
- func (sq *Condition) Column(column string) *Condition
- func (sq *Condition) Compose(column string, operator string, value ...interface{}) *Condition
- func (sq *Condition) ComposeFrom(src *Condition, operator string) *Condition
- func (sq *Condition) Cond() string
- func (sq *Condition) Eq(column string, value interface{}) *Condition
- func (sq *Condition) Gt(column string, value interface{}) *Condition
- func (sq *Condition) GtEq(column string, value interface{}) *Condition
- func (sq *Condition) In(column string, value interface{}) *Condition
- func (sq *Condition) Is() bool
- func (sq *Condition) IsFirst() bool
- func (sq *Condition) Like(column string, value interface{}) *Condition
- func (sq *Condition) Limit(value Limit) *Condition
- func (sq *Condition) Lt(column string, value interface{}) *Condition
- func (sq *Condition) LtEq(column string, value interface{}) *Condition
- func (sq *Condition) MLike(column string, value string) *Condition
- func (sq *Condition) Modifier(m string) *Condition
- func (sq *Condition) ModifierF(f string, m ...interface{}) *Condition
- func (sq *Condition) NEq(column string, value interface{}) *Condition
- func (sq *Condition) Offset(offset int) *Condition
- func (sq *Condition) Operate(operator string) *Condition
- func (sq *Condition) Or(column, operator string, value interface{}) *Condition
- func (sq *Condition) OrBetween(column string, value1, value2 interface{}) *Condition
- func (sq *Condition) OrEq(column string, value interface{}) *Condition
- func (sq *Condition) OrGt(column string, value interface{}) *Condition
- func (sq *Condition) OrGtEq(column string, value interface{}) *Condition
- func (sq *Condition) OrLt(column string, value interface{}) *Condition
- func (sq *Condition) OrLtEq(column string, value interface{}) *Condition
- func (sq *Condition) OrNEq(column string, value interface{}) *Condition
- func (sq *Condition) Order(by string) *Condition
- func (sq *Condition) PLike(column string, value string) *Condition
- func (sq *Condition) Query() string
- func (sq *Condition) Reset() *Condition
- func (sq *Condition) SLike(column string, value string) *Condition
- func (sq *Condition) Sql(end bool) string
- func (sq *Condition) Value() []interface{}
- func (sq *Condition) Values(value ...interface{}) *Condition
- type FField
- type ICond
- type IModel
- type IQuery
- type ISelect
- type Limit
- type NewCondFunc
- type NewModelFunc
- type Option
- type OptionFunc
- type Options
- type OrderBy
- type Page
- type Range
- type RangeType
- type Select
- type Time
Constants ¶
View Source
const ( Eq = "= ? " NEq = "<> ? " Lt = "< ? " LtEq = "<= ? " Gt = "> ? " GtEq = ">= ? " In = "IN ? " Like = "LIKE ? " Between = "BETWEEN ? AND ? " And = "AND" Or = "OR" )
Operate
Variables ¶
This section is empty.
Functions ¶
func AndCompose ¶ added in v1.3.0
func AndCompose[T ComposeType](cond *Condition, column string, operator string, value []T)
func IsNotFound ¶
Types ¶
type Base ¶
func (*Base) UpdateColumn ¶
func (*Base) WithResult ¶
type Column ¶ added in v1.2.26
func (*Column) WithColumn ¶ added in v1.2.26
type ComposeType ¶ added in v1.3.0
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
func (*Condition) AndBetween ¶ added in v1.2.24
func (*Condition) Column ¶
Column
- example db.Where("created_at BETWEEN ? AND ?", lastWeek, today).Find(&users)
func (*Condition) ComposeFrom ¶ added in v0.5.39
ComposeFrom 组合
func (*Condition) Like ¶
Like
@example db.Where("name LIKE ?", "%jin%").Find(&users) * Condition.Like("name","jin")
func (*Condition) Operate ¶
Operate
@param operator * @example created_at BETWEEN ? AND ? * Condition.Column("created_at").Operate("BETWEEN").Operate("AND").Values(11333,34444)
type NewCondFunc ¶ added in v1.3.0
type NewCondFunc func() ICond
type NewModelFunc ¶ added in v1.3.0
type NewModelFunc func() IModel
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option overrides behavior of Connect.
type OptionFunc ¶
type OptionFunc func(*Options)
type OrderBy ¶ added in v1.2.26
type OrderBy []*Column
OrderBy 排序(降序(大=>小)desc, 升序(小=>大)asc example: "orderBy:[{"col:"create_at","desc":true}, {"col":"id","desc":false}]
"orderBy:[{"col:"create_at,id","desc":true}]
type Page ¶
func (*Page) WithOffset ¶
type Range ¶ added in v1.3.0
type Range[T RangeType] struct { Column string `json:"col"` Operator string `json:"operator"` Min T `json:"begin"` Max T `json:"end"` }
Range 时间范围
Click to show internal directories.
Click to hide internal directories.