jaguar_orm icon indicating copy to clipboard operation
jaguar_orm copied to clipboard

InsertMany with primaryKey set to auto

Open Skuallpa opened this issue 4 years ago • 0 comments

Hello,

My model as the primary key set auto

class MyModel {
 @PrimaryKey(auto: true)
 int id;

 // .. other fields
}

When I'm trying to insert many of those object at once using insertMany, I got the error that the table has one more column that the values supplied:

await _myModelBean.insertMany(myModels);

table myTable has 3 columns but 2 values were supplied

This works if I insert using a loop like below, but this is probably much heavier in term of performance:

for (final myModel in myModels) {
    await _myModelBean.insert(myModel);
}

How to use "insertMany" with the primary key set to auto generation?

Thanks in advance

Skuallpa avatar Apr 17 '20 09:04 Skuallpa