Firestore query subcollections

后端 未结 11 1501
余生分开走
余生分开走 2020-11-22 09:24

I thought I read that you can query subcollections with the new Firebase Firestore, but I don\'t see any examples. For example I have my Firestore setup in the following way

11条回答
  •  一生所求
    2020-11-22 09:33

    I have found a solution. Please check this.

    var museums = Firestore.instance.collectionGroup('Songs').where('songName', isEqualTo: "X");
            museums.getDocuments().then((querySnapshot) {
                setState(() {
                  songCounts= querySnapshot.documents.length.toString();
                });
            });
    

    And then you can see Data, Rules, Indexes, Usage tabs in your cloud firestore from console.firebase.google.com. Finally, you should set indexes in the indexes tab.

    Fill in collection ID and some field value here. Then Select the collection group option. Enjoy it. Thanks

提交回复
热议问题