fix: reduce (#635)

* fix: management reduce optimization

* fix: reduce optimization

* fix: reduce optimization

* fix: merge master
This commit is contained in:
Fabi
2020-08-26 13:01:37 +02:00
committed by GitHub
parent 87aa97b9c7
commit 4af38b37a6
29 changed files with 184 additions and 63 deletions

View File

@@ -129,6 +129,15 @@ func PutUserGrant(db *gorm.DB, table string, grant *model.UserGrantView) error {
return save(db, grant)
}
func PutUserGrants(db *gorm.DB, table string, grants ...*model.UserGrantView) error {
save := repository.PrepareBulkSave(table)
g := make([]interface{}, len(grants))
for i, grant := range grants {
g[i] = grant
}
return save(db, g...)
}
func DeleteUserGrant(db *gorm.DB, table, grantID string) error {
delete := repository.PrepareDeleteByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
return delete(db)