How to update slice or array of struct in batches with gorm?

  Kiến thức lập trình

I see there’s an option to create new records in batches using gorm function , CreateInBatches.

// Use the Batch method to update the records in the batch
    result := db.Model(&User{}).Clauses(clause.OnConflict{
        DoUpdates: clause.AssignmentColumns([]string{"name", "age"}),
    }).CreateInBatches(batch, batchSize)

Is there an option in gorm to update record in batches using gorm function, instead of looping through each record?

LEAVE A COMMENT