如何从另一个文档angularFirestore获取来自Id的文档

时间:2018-05-14 12:12:16

标签: javascript angular firebase ionic-framework google-cloud-firestore

我试图从另一个文档中的一个文档获取信息时遇到问题,我需要的是因为它具有属性Id。

在下面的img中,我可以访问我的饮食集合并获取我的具体文档,但是我无法回来了#39;并获取我的信息ID:

enter image description here

然后,我的用户结构如下: enter image description here

一旦我暴露了我的问题,我就会向您展示我无法继续的代码:

commentsDietC: AngularFirestoreDocument<any>;
commentsDiet : Observable<any>;

 this.commentsDietC = db.doc<any>('diets/'+this.diet.idDiet);
 this.commentsDiet = this.commentsDietC.snapshotChanges()
 .map(actions => {
  if(actions.payload.data()){
    if(actions.payload.data().hasOwnProperty('commentsDiet')){

      /*HERE is where I should try to get the displayName and PhotoUrl from 
      the other document*/
      return actions.payload.data().commentsDiet;
     }
  }

});

任何帮助都会非常感激。

1 个答案:

答案 0 :(得分:0)

我认为你正在寻找这样的东西:

ActiveRecord::RecordNotFound (Couldn't find Group with 'id'=):

因此,一旦您确定有评论,此代码就会循环播放评论,然后让用户收到每条评论。

相关问题