fetchChanges method

  1. @override
Future<List<Map<String, dynamic>>> fetchChanges({
  1. required String collection,
  2. DateTime? since,
  3. String? userId,
})
override

Fetches all documents in collection that have changed since since.

When since is null a full collection fetch is performed (used on first launch or after SyncRepository.fullSync).

Pass userId to scope the query to a single user's documents when the backend enforces user-level isolation.

Implementation

@override
Future<List<Map<String, dynamic>>> fetchChanges({
  required String collection,
  DateTime? since,
  String? userId,
}) async {
  final ref = _collectionRef(collection, userId: userId);

  Query<Map<String, dynamic>> query = ref;
  if (since != null) {
    query = query.where(
      timestampField,
      isGreaterThan: Timestamp.fromDate(since),
    );
  }

  final snapshot = await query.get();
  return snapshot.docs.map(_docToMap).toList();
}