Reputation: 67
This is my Flutter code for retrieve data snapshots . This return me 0 data :
final posts = FirebaseFirestore.instance.collection('posts');
return: StreamBuilder<QuerySnapshot>(
stream: posts.doc().collection('userPosts').where('work', isEqualto: 'something').snapshot,
builder.......
);
My Firestore structure:
Upvotes: 0
Views: 124
Reputation: 83058
If I correctly understand your question, you should use a Collection group query and pass the following Stream
to the StreamBuilder
:
stream: Firestore.instance.collectionGroup('userPosts').where('work', isEqualto: 'something').snapshots();
The userPosts
collection group consists of all (sub)collections with the ID userPost
. Note that you must create an index that supports your collection group query.
Upvotes: 1