Creating records in batches

Report a typo

Suppose you want to insert records in batches into the songs table from the music database via the following piece of code:

func main() {
    ... // Connect to the `music` database using gorm.Open()

    songs := []Song{{Title: "Song1"}, {Title: "Song2"}, ..., {Title: "Song20"}}
    db.CreateInBatches(songs, 5)
}

Select how many insert operations the db.CreateInBatches(songs, 5) call would perform, and how many records would be inserted into the songs table at once per operation.

Select one option from the list
___

Create a free account to access the full topic