diff options
Diffstat (limited to 'models/db/context.go')
-rw-r--r-- | models/db/context.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/models/db/context.go b/models/db/context.go index 833c26ff6c..1cd23d453c 100644 --- a/models/db/context.go +++ b/models/db/context.go @@ -148,6 +148,17 @@ func DeleteByBean(ctx context.Context, bean interface{}) (int64, error) { return GetEngine(ctx).Delete(bean) } +// DeleteBeans deletes all given beans, beans should contain delete conditions. +func DeleteBeans(ctx context.Context, beans ...interface{}) (err error) { + e := GetEngine(ctx) + for i := range beans { + if _, err = e.Delete(beans[i]); err != nil { + return err + } + } + return nil +} + // CountByBean counts the number of database records according non-empty fields of the bean as conditions. func CountByBean(ctx context.Context, bean interface{}) (int64, error) { return GetEngine(ctx).Count(bean) |