Firestore: Get subcollection of document found with where

前端 未结 1 636
迷失自我
迷失自我 2021-01-12 07:14

I am trying to get the documents inside an subcollection which is part of an document found with the .where function

Exemple:

  • RootColl/
    • Doc A
相关标签:
1条回答
  • 2021-01-12 07:54

    A sub-collection lives under a specific document. A query as you've shared now points to a number of documents. You'll need to execute the query to determine what documents it points to, then loop over the results, and get the sub-collection for each document.

    In code:

    var query = db.collection("RootColl").where("field", "==", "1");
    query.get().then((querySnapshot) => {
      querySnapshot.forEach((document) => {
        document.ref.collection("SubColl 1").get().then((querySnapshot) => {
          ...
        });
      });
    });
    
    0 讨论(0)
提交回复
热议问题