query method

Stream<Iterable<T>> query({
  1. required QueryTransformer<T> spec,
  2. required String type,
  3. DocumentReference<Object?>? parent,
  4. bool includeMetadataChanges = false,
})

Query some data from a Firestore collection with name type in the document with DocumentReference parent according to the given rule in the specification.

Will return a Stream of Iterable with items. The stream will emmit values each time specified documents in the Firestore get updated.

Eg:

This code will query all the documents in the global collection People in Firestore.

peopleRepository.query(
  specification: ComplexSpecification([]),
  type: 'People',
  parent: null,
);

This will query for documents with name Hilda in the same collection.

peopleRepository.query(
  specification: ComplexSpecification([
    ComplexWhere('name', isEqualTo: 'Hilda'),
  ]),
  type: 'People',
  parent: null,
);

Implementation

Stream<Iterable<T>> query({
  required QueryTransformer<T> spec,
  required String type,
  DocumentReference? parent,
  bool includeMetadataChanges = false,
}) {
  return _query2stream(_merge(type, parent), spec, includeMetadataChanges);
}