Merge db.Iterate and IterateObjects (#21641)

These two functions are similiar, merge them.
This commit is contained in:
Lunny Xiao 2022-10-31 23:51:14 +08:00 committed by GitHub
parent 4ae3f76217
commit 9a70a12a34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 77 additions and 51 deletions

View file

@ -30,10 +30,9 @@ import (
func iterateRepositories(ctx context.Context, each func(*repo_model.Repository) error) error {
err := db.Iterate(
ctx,
new(repo_model.Repository),
builder.Gt{"id": 0},
func(idx int, bean interface{}) error {
return each(bean.(*repo_model.Repository))
func(ctx context.Context, bean *repo_model.Repository) error {
return each(bean)
},
)
return err