mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 16:10:55 +00:00
Add GetCond func to querySet
This commit is contained in:
parent
90999717dd
commit
5c76f62103
@ -153,6 +153,11 @@ func (o querySet) SetCond(cond *Condition) QuerySeter {
|
|||||||
return &o
|
return &o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get condition from QuerySeter
|
||||||
|
func (o querySet) GetCond() *Condition {
|
||||||
|
return o.cond
|
||||||
|
}
|
||||||
|
|
||||||
// return QuerySeter execution result number
|
// return QuerySeter execution result number
|
||||||
func (o *querySet) Count() (int64, error) {
|
func (o *querySet) Count() (int64, error) {
|
||||||
return o.orm.alias.DbBaser.Count(o.orm.db, o, o.mi, o.cond, o.orm.alias.TZ)
|
return o.orm.alias.DbBaser.Count(o.orm.db, o, o.mi, o.cond, o.orm.alias.TZ)
|
||||||
|
10
orm/types.go
10
orm/types.go
@ -145,6 +145,16 @@ type QuerySeter interface {
|
|||||||
// //sql-> WHERE T0.`profile_id` IS NOT NULL AND NOT T0.`Status` IN (?) OR T1.`age` > 2000
|
// //sql-> WHERE T0.`profile_id` IS NOT NULL AND NOT T0.`Status` IN (?) OR T1.`age` > 2000
|
||||||
// num, err := qs.SetCond(cond1).Count()
|
// num, err := qs.SetCond(cond1).Count()
|
||||||
SetCond(*Condition) QuerySeter
|
SetCond(*Condition) QuerySeter
|
||||||
|
// get condition from QuerySeter.
|
||||||
|
// sql's where condition
|
||||||
|
// cond := orm.NewCondition()
|
||||||
|
// cond = cond.And("profile__isnull", false).AndNot("status__in", 1)
|
||||||
|
// qs = qs.SetCond(cond)
|
||||||
|
// cond = qs.GetCond()
|
||||||
|
// cond := cond.Or("profile__age__gt", 2000)
|
||||||
|
// //sql-> WHERE T0.`profile_id` IS NOT NULL AND NOT T0.`Status` IN (?) OR T1.`age` > 2000
|
||||||
|
// num, err := qs.SetCond(cond).Count()
|
||||||
|
GetCond() *Condition
|
||||||
// add LIMIT value.
|
// add LIMIT value.
|
||||||
// args[0] means offset, e.g. LIMIT num,offset.
|
// args[0] means offset, e.g. LIMIT num,offset.
|
||||||
// if Limit <= 0 then Limit will be set to default limit ,eg 1000
|
// if Limit <= 0 then Limit will be set to default limit ,eg 1000
|
||||||
|
Loading…
Reference in New Issue
Block a user