orm add Exist func
Showing
2 changed files
with
6 additions
and
0 deletions
| ... | @@ -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) | ... | ... |
-
Please register or sign in to post a comment