5d55ca19 by slene

orm add Exist func

1 parent 3f91dfbc
...@@ -114,6 +114,11 @@ func (o *querySet) Count() (int64, error) { ...@@ -114,6 +114,11 @@ func (o *querySet) Count() (int64, error) {
114 return o.orm.alias.DbBaser.Count(o.orm.db, o, o.mi, o.cond, o.orm.alias.TZ) 114 return o.orm.alias.DbBaser.Count(o.orm.db, o, o.mi, o.cond, o.orm.alias.TZ)
115 } 115 }
116 116
117 func (o *querySet) Exist() bool {
118 cnt, _ := o.orm.alias.DbBaser.Count(o.orm.db, o, o.mi, o.cond, o.orm.alias.TZ)
119 return cnt > 0
120 }
121
117 func (o *querySet) Update(values Params) (int64, error) { 122 func (o *querySet) Update(values Params) (int64, error) {
118 return o.orm.alias.DbBaser.UpdateBatch(o.orm.db, o, o.mi, o.cond, values, o.orm.alias.TZ) 123 return o.orm.alias.DbBaser.UpdateBatch(o.orm.db, o, o.mi, o.cond, values, o.orm.alias.TZ)
119 } 124 }
......
...@@ -50,6 +50,7 @@ type QuerySeter interface { ...@@ -50,6 +50,7 @@ type QuerySeter interface {
50 OrderBy(...string) QuerySeter 50 OrderBy(...string) QuerySeter
51 RelatedSel(...interface{}) QuerySeter 51 RelatedSel(...interface{}) QuerySeter
52 Count() (int64, error) 52 Count() (int64, error)
53 Exist() bool
53 Update(Params) (int64, error) 54 Update(Params) (int64, error)
54 Delete() (int64, error) 55 Delete() (int64, error)
55 PrepareInsert() (Inserter, error) 56 PrepareInsert() (Inserter, error)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!