0

enter image description hereThis is my firebase database structure I want stream chats only where the participant's id is equal to the current user id please give a good solution with stream builder flutter and it should be based on firebase store one

Another thing is firebase suggests creating composite I also create this as well the data is retrieved as an empty array

I tried the query below attached but it not worked

Stream<QuerySnapshot<Object?>> groupChatsStream() {
CollectionReference groupChatsRef =
    FirebaseFirestore.instance.collection('todo');
Query query = groupChatsRef.where('participants', arrayContains: '11');

return query.snapshots();}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I think that this answer can help you https://stackoverflow.com/questions/46573014/firestore-query-subcollections – Camillo bucciarelli Mar 18 '23 at 12:01
  • You're using `arrayContains`, but the `participants` in your screenshot is not an array but a *collection*. So the query doesn't match your data structure, and won't find any matches. As Camillo linked, you can [use a collection group query](https://firebase.google.com/docs/firestore/query-data/queries#collection-group-query) to query across all collections named `participants`. When doing that, the result will be documents from the `participants` collection though. If you want to get todo documents based on their participants, the information will have to be in each todo couemtn. – Frank van Puffelen Mar 18 '23 at 14:14

0 Answers0