Skip to content

Commit

Permalink
feat(resource): support batch in BulkUpsert
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmatrhd committed Sep 15, 2023
1 parent 3bd8e74 commit c3d93eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/store/postgres/resource_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (r *ResourceRepository) BulkUpsert(ctx context.Context, resources []*domain
if len(models) > 0 {
return r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
// upsert clause is moved to model.Resource.BeforeCreate() (gorm's hook) to apply the same for associations (model.Resource.Children)
if err := r.db.Create(models).Error; err != nil {
if err := r.db.CreateInBatches(models, 1000).Error; err != nil {
return err
}

Expand Down

0 comments on commit c3d93eb

Please sign in to comment.