putMany method
Puts the given objects
into this Box in a single transaction.
Returns a list of all IDs of the inserted Objects.
Implementation
List<int> putMany(List<T> objects, {PutMode mode = PutMode.put}) {
if (objects.isEmpty) return [];
final putIds = List<int>.filled(objects.length, 0);
InternalStoreAccess.runInTransaction(_store, TxMode.write,
(Transaction tx) {
if (_hasToOneRelations) {
objects.forEach((object) => _putToOneRelFields(object, mode, tx));
}
final cursor = tx.cursor(_entity);
final cMode = _getOBXPutMode(mode);
for (var i = 0; i < objects.length; i++) {
final object = objects[i];
_builder.fbb.reset();
final id = _entity.objectToFB(object, _builder.fbb);
final newId = C.cursor_put_object4(
cursor.ptr, _builder.bufPtr, _builder.fbb.size(), cMode);
putIds[i] = _handlePutObjectResult(object, id, newId);
}
if (_hasToManyRelations) {
objects.forEach((object) => _putToManyRelFields(object, mode, tx));
}
_builder.resetIfLarge();
});
return putIds;
}