Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 获取具有多个调用的对象的数据_Javascript_Rxjs_Google Cloud Firestore - Fatal编程技术网

Javascript 获取具有多个调用的对象的数据

Javascript 获取具有多个调用的对象的数据,javascript,rxjs,google-cloud-firestore,Javascript,Rxjs,Google Cloud Firestore,我正在使用一个文档数据库(googlecloudfirestore),并试图获取一组深度嵌套对象的所有数据。我还没有找到一种方法,可以通过一个简单的调用向Firestore请求所有数据 我的数据如下所示 Assessment: { documentid: string name: string, email: string, responses: Response[] } Response: { documentid: string questio

我正在使用一个文档数据库(googlecloudfirestore),并试图获取一组深度嵌套对象的所有数据。我还没有找到一种方法,可以通过一个简单的调用向Firestore请求所有数据

我的数据如下所示

Assessment: {
    documentid: string
    name: string,
    email: string,
    responses: Response[]
}
Response: {
    documentid: string
    question: string,
    answer: string
}
因此,我试图从评估收集中获取所有评估——这会带回所有数据,但评估中的响应除外,因此我需要再打一次电话来获取这些数据

这是我目前正在使用的代码,但它只带来1个附带回复的评估,而不是我预期的150个

this.db
  .collection("Assessments")
  .snapshotChanges()
  .pipe(
    //append the documentid to each assessment
    flatMap(actions => {
      return actions.map(a => {
        const assessment = a.payload.doc.data() as Assessment;
        assessment.documentid = a.payload.doc.id;
        return assessment as Assessment;
      });
    }),
    concatMap(assessment => {
      return (
        this.documentDB
          .collection("Assessments")
          .doc(assessment.documentid)
          .collection("Responses")
          .snapshotChanges()
          .pipe(
              //append the documentid to each response
              map(actions => {
                return actions.map(a => {
                  const response = a.payload.doc.data() as WfResponse;
                  response.documentid = a.payload.doc.id;
                  return response;
                });
              }),
              //append the responses to the originial assessment object
              .map(responses => {
                responses.sort(this.sortBySortOrder);
                assessment.responses = responses;
                return assessment;
              })
          );
      );
    })
  )
  .subscribe(assessments => {
    this.queryResult.push(assessments as Assessment);
  });

这似乎是谷歌云Firestore不支持的东西

其他地方也有人以其他方式问过这个问题,他们似乎一直在确认Google Cloud Firestore只支持肤浅的查询

见:


您是否尝试过调试正在发生的事情?您所有的评估都是通过
concatMap(评估=>{
)进行的吗?