I am trying to query a subcollection from a StreamBuilder but the query returns zero documents, although there is a document in the subcollection. Querying the parent collection returns the correct number of documents and the document ID passed to the subcollection has been verified. What am I missing?
StreamBuilder<QuerySnapshot>(
stream: _firestore
.collection('books')
.document(documentID)
.collection('enquiries')
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Text('You have not received any enquiries yet!');
} else {
final numberOfDocs = snapshot.data.documents.length;
print(numberOfDocs); // HELP HERE! returns 0, although a document exists in the subcollection
print(documentID); // returns the expected document ID
...