count method

AggregateQuery count()

Returns an AggregateQuery that counts the documents in the result set of this query, without downloading the documents.

The count is computed on the server: it fails when the client is offline.

final AggregateQuerySnapshot snapshot = await firestore
    .collection('cities')
    .where('state', isEqualTo: 'CA')
    .count()
    .get();
print(snapshot.count);

Implementation

AggregateQuery count() => AggregateQueryInternal.create(
  this,
  <AggregateField>[AggregateField.count()],
);