updateLastSyncTime method

Future<void> updateLastSyncTime(
  1. String collectionName,
  2. DateTime syncTime
)

Update last sync time for a collection

Implementation

Future<void> updateLastSyncTime(
  String collectionName,
  DateTime syncTime,
) async {
  _ensureInitialized();

  await _isar.writeTxn(() async {
    final records = await _isar.dataRecords
        .filter()
        .collectionNameEqualTo(collectionName)
        .findAll();

    for (final record in records) {
      record.lastSyncedAt = syncTime;
      await _isar.dataRecords.put(record);
    }
  });
}