Commit 5d55ca19 authored by slene's avatar slene

orm add Exist func

parent 3f91dfbc
...@@ -114,6 +114,11 @@ func (o *querySet) Count() (int64, error) { ...@@ -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) 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) { 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) return o.orm.alias.DbBaser.UpdateBatch(o.orm.db, o, o.mi, o.cond, values, o.orm.alias.TZ)
} }
......
...@@ -50,6 +50,7 @@ type QuerySeter interface { ...@@ -50,6 +50,7 @@ type QuerySeter interface {
OrderBy(...string) QuerySeter OrderBy(...string) QuerySeter
RelatedSel(...interface{}) QuerySeter RelatedSel(...interface{}) QuerySeter
Count() (int64, error) Count() (int64, error)
Exist() bool
Update(Params) (int64, error) Update(Params) (int64, error)
Delete() (int64, error) Delete() (int64, error)
PrepareInsert() (Inserter, error) PrepareInsert() (Inserter, error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment