findStreamByQuery method

Stream<List<Map<String, dynamic>>> findStreamByQuery({
  1. required CollectionReferenceQuery<Map<String, dynamic>>? collectionReferenceQuery,
  2. required String whereDescription,
})

Finds a Stream of List<Map<String, dynamic>> based on given collectionReferenceQuery and whereDescription.

If _tryAddLocalId is true then your data will also contain a local id field based on the _idFieldName specified in the constructor. Add this id field to your T and you will have easy access to the document id at any time.

If _tryAddLocalDocumentReference is true then your data will also contain a local reference field based on the _documentReferenceFieldName specified in the constructor. Add this reference field to your T and you will have easy access to the document reference at any time.

If you rather want to retrieve data in the form of list of T consider using the findStreamByQueryWithConverter method instead.

Implementation

Stream<List<Map<String, dynamic>>> findStreamByQuery({
  required CollectionReferenceQuery<Map<String, dynamic>>?
      collectionReferenceQuery,
  required String whereDescription,
}) {
  _log.info(
    message: 'Finding stream by query..',
    sensitiveData: _shouldNotSensitiveInfo
        ? null
        : SensitiveData(
            path: _collectionPath(),
            whereDescription: whereDescription,
          ),
  );
  return collectionReferenceQuery!(findCollection()).snapshots().map(
        (event) => event.docs.map((e) => e.data()).toList(),
      );
}