queryData method
Future<List>
queryData(
- String collectionId, {
- required Map<
String, dynamic> where, - required String orderBy,
- bool descending = true,
- int? limit,
- int? offset,
- List<
Object?> ? startAfter,
override
Implementation
@override
Future<List> queryData(String collectionId,
{required Map<String, dynamic> where,
required String orderBy,
bool descending = true,
int? limit,
int? offset,
List<Object?>? startAfter}) async {
logger.finest('before');
await initialize();
logger.finest('after');
assert(_db != null);
CollectionReference collectionRef = _db!.collection(collectionId);
Query<Object?> query = collectionRef.orderBy(orderBy, descending: descending);
where.map((mid, value) {
query = query.where(mid, isEqualTo: value);
return MapEntry(mid, value);
});
if (limit != null) query = query.limit(limit);
if (startAfter != null && startAfter.isNotEmpty) query = query.startAfter(startAfter);
return await query.get().then((snapshot) {
return snapshot.docs.map((doc) {
//logger.finest(doc.data()!.toString());
return doc.data()! as Map<String, dynamic>;
}).toList();
});
}