getDocumentsCount method

Future<int> getDocumentsCount({
  1. required Query<Object?> query,
})

Retrieves int count of the documents within specific query.

query is a query. onDocumentSnapshot is a method with return type of an object.

Implementation

Future<int> getDocumentsCount({
  required Query query,
}) async {
  _loggingService.log('FirestoreHelper.getDocumentsCount: Query: ${query.parameters}');

  final querySnap = await query.count().get();
  final count = querySnap.count;

  return count;
}