1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 10:00:51 +00:00

orm add Exist func

This commit is contained in:
slene 2013-10-12 06:57:14 +08:00
parent 3f91dfbca3
commit 5d55ca19be
2 changed files with 6 additions and 0 deletions

View File

@ -114,6 +114,11 @@ func (o *querySet) Count() (int64, error) {
return o.orm.alias.DbBaser.Count(o.orm.db, o, o.mi, o.cond, o.orm.alias.TZ)
}
func (o *querySet) Exist() bool {
cnt, _ := o.orm.alias.DbBaser.Count(o.orm.db, o, o.mi, o.cond, o.orm.alias.TZ)
return cnt > 0
}
func (o *querySet) Update(values Params) (int64, error) {
return o.orm.alias.DbBaser.UpdateBatch(o.orm.db, o, o.mi, o.cond, values, o.orm.alias.TZ)
}

View File

@ -50,6 +50,7 @@ type QuerySeter interface {
OrderBy(...string) QuerySeter
RelatedSel(...interface{}) QuerySeter
Count() (int64, error)
Exist() bool
Update(Params) (int64, error)
Delete() (int64, error)
PrepareInsert() (Inserter, error)