Documentation ¶
Index ¶
- type Scopes
- func Limit(limit int) *Scopes
- func New() *Scopes
- func Offset(offset int) *Scopes
- func OrderBy(column string, reorder ...string) *Scopes
- func OrderByAsc(column string) *Scopes
- func OrderByDesc(column string) *Scopes
- func OrderByRaw(sql interface{}) *Scopes
- func Page(page, prePage int) *Scopes
- func Skip(offset int) *Scopes
- func Take(limit int) *Scopes
- func Unless(condition bool, f func(db *gorm.DB) *gorm.DB) *Scopes
- func When(condition bool, f func(db *gorm.DB) *gorm.DB) *Scopes
- func Where(query interface{}, args ...interface{}) *Scopes
- func WhereBetween(field string, start, end interface{}) *Scopes
- func WhereEgt(field string, value interface{}) *Scopes
- func WhereElt(field string, value interface{}) *Scopes
- func WhereEq(field string, value interface{}) *Scopes
- func WhereGt(field string, value interface{}) *Scopes
- func WhereIn(field string, values ...interface{}) *Scopes
- func WhereLike(field string, value interface{}) *Scopes
- func WhereLt(field string, value interface{}) *Scopes
- func WhereNe(field string, value interface{}) *Scopes
- func WhereNot(query interface{}, args ...interface{}) *Scopes
- func WhereNotBetween(field string, start, end interface{}) *Scopes
- func WhereNotIn(field string, values ...interface{}) *Scopes
- func WhereNotLike(field string, value interface{}) *Scopes
- func WhereNotNull(field string) *Scopes
- func WhereNull(field string) *Scopes
- func (s *Scopes) Add(scopes ...func(*gorm.DB) *gorm.DB) *Scopes
- func (s *Scopes) Apply(db *gorm.DB) *gorm.DB
- func (s *Scopes) Limit(limit int) *Scopes
- func (s *Scopes) Offset(offset int) *Scopes
- func (s *Scopes) OrderBy(column string, reorder ...string) *Scopes
- func (s *Scopes) OrderByAsc(column string) *Scopes
- func (s *Scopes) OrderByDesc(column string) *Scopes
- func (s *Scopes) OrderByRaw(sql interface{}) *Scopes
- func (s *Scopes) Page(page, prePage int) *Scopes
- func (s *Scopes) Scope() func(*gorm.DB) *gorm.DB
- func (s *Scopes) Scopes() []func(*gorm.DB) *gorm.DB
- func (s *Scopes) Skip(offset int) *Scopes
- func (s *Scopes) Take(limit int) *Scopes
- func (s *Scopes) Unless(condition bool, fc func(*gorm.DB) *gorm.DB) *Scopes
- func (s *Scopes) When(condition bool, fc func(*gorm.DB) *gorm.DB) *Scopes
- func (s *Scopes) Where(query interface{}, args ...interface{}) *Scopes
- func (s *Scopes) WhereBetween(column string, start, end interface{}) *Scopes
- func (s *Scopes) WhereEgt(column string, value interface{}) *Scopes
- func (s *Scopes) WhereElt(column string, value interface{}) *Scopes
- func (s *Scopes) WhereEq(column string, value interface{}) *Scopes
- func (s *Scopes) WhereGt(column string, value interface{}) *Scopes
- func (s *Scopes) WhereIn(column string, values ...interface{}) *Scopes
- func (s *Scopes) WhereLike(column string, value interface{}) *Scopes
- func (s *Scopes) WhereLt(column string, value interface{}) *Scopes
- func (s *Scopes) WhereNe(column string, value interface{}) *Scopes
- func (s *Scopes) WhereNot(query interface{}, args ...interface{}) *Scopes
- func (s *Scopes) WhereNotBetween(column string, start, end interface{}) *Scopes
- func (s *Scopes) WhereNotIn(column string, values ...interface{}) *Scopes
- func (s *Scopes) WhereNotLike(column string, value interface{}) *Scopes
- func (s *Scopes) WhereNotNull(column string) *Scopes
- func (s *Scopes) WhereNull(column string) *Scopes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scopes ¶
func OrderBy ¶
OrderBy add order by condition
OrderBy("name") OrderBy("name", "desc") OrderBy("name", "asc")
func OrderByRaw ¶
func OrderByRaw(sql interface{}) *Scopes
OrderByRaw add order by raw condition
OrderByRaw("name desc") OrderByRaw("name asc") OrderByRaw("name desc, age asc") OrderByRaw("FIELD(id, 3, 1, 2)")
func Unless ¶
Unless if condition is false, apply the scopes
Unless(false, func(db *gorm.DB) *gorm.DB { return db.Where("name = ?", "Flc") }) Unless(true, func(db *gorm.DB) *gorm.DB { return db.Where("name = ?", "Flc") })
func When ¶
When if condition is true, apply the scopes
When(true, func(db *gorm.DB) *gorm.DB { return db.Where("name = ?", "Flc") }) When(false, func(db *gorm.DB) *gorm.DB { return db.Where("name = ?", "Flc") })
func Where ¶
func Where(query interface{}, args ...interface{}) *Scopes
Where add where condition
Where("name = ?", "Flc") Where("name = ? AND age = ?", "Flc", 20)
func WhereIn ¶
WhereIn add where in condition
WhereIn("name", []string{"WhereInUser1", "WhereInUser2"}) WhereIn("age", []int{18, 20}) WhereIn("name", "WhereInUser1", "WhereInUser2")
func WhereLike ¶
WhereLike add where like condition
WhereLike("name", "Flc") WhereLike("name", "Flc%") WhereLike("name", "%Flc") WhereLike("name", "%Flc%")
func WhereNot ¶
func WhereNot(query interface{}, args ...interface{}) *Scopes
WhereNot add where not condition
WhereNot("name = ?", "Flc") WhereNot("name = ? AND age = ?", "Flc", 20)
func WhereNotBetween ¶
WhereNotBetween add where not between condition
WhereNotBetween("age", 18, 20)
func WhereNotIn ¶
WhereNotIn add where not in condition
WhereNotIn("name", []string{"WhereInUser1", "WhereInUser2"}) WhereNotIn("age", []int{18, 20}) WhereNotIn("name", "WhereInUser1", "WhereInUser2")
func WhereNotLike ¶
WhereNotLike add where not like condition
WhereNotLike("name", "Flc") WhereNotLike("name", "Flc%") WhereNotLike("name", "%Flc") WhereNotLike("name", "%Flc%")
func (*Scopes) OrderBy ¶
OrderBy add order by condition
OrderBy("name") OrderBy("name", "desc") OrderBy("name", "asc")
func (*Scopes) OrderByRaw ¶
OrderByRaw add order by raw condition
OrderByRaw("name desc") OrderByRaw("name asc") OrderByRaw("name desc, age asc") OrderByRaw("FIELD(id, 3, 1, 2)")
func (*Scopes) Unless ¶
Unless if condition is false, apply the scopes
Unless(false, func(db *gorm.DB) *gorm.DB { return db.Where("name = ?", "Flc") }) Unless(true, func(db *gorm.DB) *gorm.DB { return db.Where("name = ?", "Flc") })
func (*Scopes) When ¶
When if condition is true, apply the scopes
When(true, func(db *gorm.DB) *gorm.DB { return db.Where("name = ?", "Flc") }) When(false, func(db *gorm.DB) *gorm.DB { return db.Where("name = ?", "Flc") })
func (*Scopes) Where ¶
Where add where condition
Where("name = ?", "Flc") Where("name = ? AND age = ?", "Flc", 20)
func (*Scopes) WhereIn ¶
WhereIn add where in condition
WhereIn("name", []string{"WhereInUser1", "WhereInUser2"}) WhereIn("age", []int{18, 20}) WhereIn("name", "WhereInUser1", "WhereInUser2")
func (*Scopes) WhereLike ¶
WhereLike add where like condition
WhereLike("name", "Flc") WhereLike("name", "Flc%") WhereLike("name", "%Flc") WhereLike("name", "%Flc%")
func (*Scopes) WhereNot ¶
WhereNot add where not condition
WhereNot("name = ?", "Flc") WhereNot("name = ? AND age = ?", "Flc", 20)
func (*Scopes) WhereNotBetween ¶
WhereNotBetween add where not between condition
WhereNotBetween("age", 18, 20)
func (*Scopes) WhereNotIn ¶
WhereNotIn add where not in condition
WhereNotIn("name", []string{"WhereInUser1", "WhereInUser2"}) WhereNotIn("age", []int{18, 20}) WhereNotIn("name", "WhereInUser1", "WhereInUser2")
func (*Scopes) WhereNotLike ¶
WhereNotLike add where not like condition
WhereNotLike("name", "Flc") WhereNotLike("name", "Flc%") WhereNotLike("name", "%Flc") WhereNotLike("name", "%Flc%")