updateServerGeneratedIds method
Future<void>
updateServerGeneratedIds(
{ - required UpdateServerGeneratedIdModel model,
})
inherited
Implementation
Future<void> updateServerGeneratedIds({
required UpdateServerGeneratedIdModel model,
}) async {
final opLogs = isar.opLogs
.filter()
.clientReferenceIdEqualTo(model.clientReferenceId)
.findAllSync();
for (final oplog in opLogs
.where(
(element) => element.entityType.name != DataModelType.service.name,
)
.toList()) {
final entry = OpLogEntry.fromOpLog<T>(oplog);
OpLogEntry updatedEntry = entry.copyWith(
serverGeneratedId: model.serverGeneratedId,
additionalIds: model.additionalIds,
rowVersion: model.rowVersion,
nonRecoverableError: model.nonRecoverableError,
);
if (entry.syncedUp) {
updatedEntry = updatedEntry.copyWith(
syncedDown: true,
syncedDownOn: DateTime.now(),
);
}
final updatedOplog = updatedEntry.oplog;
isar.writeTxnSync(() {
isar.opLogs.putSync(updatedOplog);
});
}
return;
}