getPendingDownSync method

Future<List<OpLogEntry<T>>> getPendingDownSync(
  1. DataModelType type, {
  2. required String createdBy,
})

Implementation

Future<List<OpLogEntry<T>>> getPendingDownSync(
  DataModelType type, {
  required String createdBy,
}) async {
  var oplogs = isar.opLogs
      .filter()
      .syncedUpEqualTo(true)
      .syncDownRetryCountLessThan(
          DigitDataModelSingleton().syncDownRetryCount)
      .syncedDownEqualTo(false)
      .entityTypeEqualTo(type)
      .findAllSync();

  oplogs = oplogs
      .sortedBy((element) => element.createdAt)
      .where(
        (element) =>
            element.entityType != DataModelType.service &&
            element.entityType != DataModelType.userLocation &&
            element.entityType != DataModelType.complaints,
        // Added service so that we don't get the response from the server
      )
      .toList();

  return oplogs.map((e) => OpLogEntry.fromOpLog<T>(e)).toList();
}