Documentation ¶
Index ¶
- Constants
- func ANDCompose[T ComposeType](cond *Condition, column string, ac *Array[T])
- func AddSQLFunc(flag int, fn string)
- func IN[T ComposeType](cond *Condition, column string, ac *Array[T])
- func IsNotFound(db *gorm.DB) int
- func IsValid(r interface{}) bool
- func MLike(value string) string
- func ORCompose[T ComposeType](cond *Condition, column string, ac *Array[T])
- func PLike(value string) string
- func SLike(value string) string
- func SQLFunc(flag int) string
- type Array
- 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
- func (col *Column) AS(newCol string) *Column
- func (col *Column) Check(filters []FField) *Column
- func (col *Column) GetColumn() []string
- func (col *Column) SetColumn(cols []string)
- func (col *Column) Sql(convert ColumnConvert) string
- func (col *Column) With(column string) *Column
- func (col *Column) WithFunc(fg int) *Column
- type ColumnConvert
- 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) 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) NEq(column string, value interface{}) *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(full bool) string
- func (sq *Condition) Value() []interface{}
- func (sq *Condition) Values(value ...interface{}) *Condition
- func (sq *Condition) WithIgnore(ig int) *Condition
- func (sq *Condition) WithLimit(value Limit) *Condition
- func (sq *Condition) WithOffset(offset int) *Condition
- type FField
- type Flag
- type GroupBy
- 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 Range2
- type SQL
- type Select
- type Time
- type Time2
Constants ¶
View Source
const ( Eq = "= ?" NEq = "<> ?" Lt = "< ?" LtEq = "<= ?" Gt = "> ?" GtEq = ">= ?" In = "IN ?" Between = "BETWEEN ? AND ?" And = "AND" Or = "OR" Like = "LIKE ?" )
Operate
View Source
const ( KIgOrderBy = 0x01 KIgLimit = 0x02 KIgOffset = 0x04 KIgAll = 0xffff )
View Source
const ( KSQLFunc = iota KSQLCount KSQLMax KSQLMin KSQLWeek KSQLYear KSQLMonth KSQLSum KSQLAbs KSQLFloor KSQLGreatest KSQLLeast KSQLUpper KSQLLower KSQLTrim KSQLRTrim KSQLLTrim KSQLCharLength KSQLConcat KSQLReverse )
Variables ¶
This section is empty.
Functions ¶
func ANDCompose ¶ added in v1.3.15
func ANDCompose[T ComposeType](cond *Condition, column string, ac *Array[T])
func AddSQLFunc ¶ added in v1.3.8
func IsNotFound ¶
Types ¶
type Array ¶ added in v1.3.34
type Array[T ComposeType] struct { Size int Value []T }
type Base ¶
func (*Base) UpdateColumn ¶
func (*Base) WithResult ¶
type Column ¶ added in v1.2.26
type Column struct { Flag Column string `form:"col" json:"col"` As string `form:"-" json:"-"` Desc bool `form:"desc" json:"desc"` //(降序(大=>小)desc, 升序(小=>大)asc }
func WithColumn ¶ added in v1.3.9
func WithColumns ¶ added in v1.3.9
func (*Column) Sql ¶ added in v1.2.26
func (col *Column) Sql(convert ColumnConvert) string
type ColumnConvert ¶ added in v1.3.24
type ComposeType ¶ added in v1.3.0
type Condition ¶
type Condition struct { Ignore int Limit Limit Offset int OrderBy string // 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)
func (*Condition) WithIgnore ¶ added in v1.3.11
func (*Condition) WithOffset ¶ added in v1.3.11
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 common.IntegerType] struct { Column string `json:"col"` Operator string `json:"operator"` Min T `json:"begin"` Max T `json:"end"` }
Range 时间范围
type Range2 ¶ added in v1.3.40
type Range2[T common.IntegerType] struct { Column string `json:"col"` Op string `json:"op"` Min T `json:"start"` Max T `json:"end"` }
Range2 时间范围
Click to show internal directories.
Click to hide internal directories.