I have a Publication object and i’d like to insert a batch of them.
Two options:
1. Insert only via the Entity
Copy code
for loop
Publication.new { ... }
2. Insert via entity table
Copy code
Publication.table.batchInsert
1? 2? I’m not sure
s
spand
05/28/2021, 2:38 PM
One would think batchInsert would be appropriate for inserting a batch
b
Bogdan
05/29/2021, 12:39 PM
well, there is not much difference. If you have Entity everywhere, then the first one. Also, if, after insertion, these Entities are used below (in a transaction), then there is no additional select in the case of the first option
r
Renaud
05/31/2021, 9:05 AM
Actually there is a little difference :
batchInsert
returns
List<ResultRow>
so this can help to notify if something was inserted or not. With a “manual” loop +