query method

Stream<Iterable<T>> query({
  1. required QueryTransformer spec,
  2. DocumentReference<Object?>? parent,
  3. 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 = PeopleRepository('People');
peopleRepository.query(
  specification: ComplexSpecification([]),
  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 spec,
  DocumentReference? parent,
  bool includeMetadataChanges = false,
}) {
  return _query2stream(_merge(parent), spec, includeMetadataChanges);
}