-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
type:questiongeneral questionsgeneral questions
Description
Hi all!
Your Question
I tried to pass an iterator to the method CreateInBatches:
modelsIterator := func(contacts []domain.Contact) iter.Seq[contactModel] {
return func(yield func(contactModel) bool) {
for _, contact := range contacts {
model := domainToModel(contact)
if !yield(model) {
return
}
}
}
}
tx := db.CreateInBatches(modelsIterator(contacts), 1000)But I got this error:
unsupported data type: iter.Seq[contactModel]: Table not set, please set it like: db.Model(&user) or db.Table("users")
Are iterators supported by CreateInBatches?
The document you expected this should be explained
It's not mentioned in Create Batch Insert.
Expected answer
Is there a way to create in batches with an iterator to avoid allocating a big array in memory?
Metadata
Metadata
Assignees
Labels
type:questiongeneral questionsgeneral questions