mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-04 17:34:49 -04:00
Merge db.Iterate and IterateObjects (#21641)
These two functions are similiar, merge them.
This commit is contained in:
parent
4ae3f76217
commit
9a70a12a34
12 changed files with 77 additions and 51 deletions
|
@ -8,9 +8,6 @@ import (
|
|||
"context"
|
||||
"database/sql"
|
||||
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
|
@ -121,13 +118,6 @@ func WithTx(f func(ctx context.Context) error, stdCtx ...context.Context) error
|
|||
return sess.Commit()
|
||||
}
|
||||
|
||||
// Iterate iterates the databases and doing something
|
||||
func Iterate(ctx context.Context, tableBean interface{}, cond builder.Cond, fun func(idx int, bean interface{}) error) error {
|
||||
return GetEngine(ctx).Where(cond).
|
||||
BufferSize(setting.Database.IterateBufferSize).
|
||||
Iterate(tableBean, fun)
|
||||
}
|
||||
|
||||
// Insert inserts records into database
|
||||
func Insert(ctx context.Context, beans ...interface{}) error {
|
||||
_, err := GetEngine(ctx).Insert(beans...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue