Rxjs Angular 5 Firestore连接3可观测数据库

Rxjs Angular 5 Firestore连接3可观测数据库,rxjs,observable,angular5,google-cloud-firestore,Rxjs,Observable,Angular5,Google Cloud Firestore,如何将3个firestore集合加入到一起,答案如下 恩戈尼尼特(){ 下面的代码将为您提供URL ngOnInit() { this.products = this.afs.collection('/products', ref => ref.where('publish', '==', true)) .snapshotChanges().map(actions => { return actions.map(a => { const dat

如何将3个firestore集合加入到一起,答案如下 恩戈尼尼特(){


下面的代码将为您提供URL

ngOnInit() {

    this.products = this.afs.collection('/products', ref => ref.where('publish', '==', true))   .snapshotChanges().map(actions => {
    return actions.map(a => {
      const data = a.payload.doc.data();
      const id = a.payload.doc.id;
      return this.afs.collection('users').doc(data.uid).snapshotChanges().map(userActions=>{
        return userActions.payload.data();
      }).map(user=>{
        return this.afs.collection('productPhotos').doc(id).snapshotChanges().map(photoActions=>{
            return photoActions.payload.data();
        }).map(res=>{
          return { id:id, url:res.url, displayName:user.displayName, email:user.email, ...data };
        })
      }).flatMap(merge => Observable.combineLatest(merge))
    });
    }).flatMap(merge => Observable.combineLatest(merge)).map(data => {
    return [].concat(...data).map(d => {
      return d;
   })
 })

}

我不清楚你的stackblitz代码,据我所知,我在这里发布了一个类似的答案。希望有帮助。谢谢!我尝试将你的解决方案应用于此。谢谢链接2工作正常,我现在尝试添加第三个表。这在3个表中很棘手。你能看看stackblitz链接吗请用最少的代码编辑你的问题并简要说明您的问题。Samuel Liew,c69,这是Angular 5和firestore。我已经回答了我自己的问题。谢谢,它有效,还有一个问题,因为产品是可观察的对象,它在ngFor中循环ngFor有问题,请您帮助查看。有多张照片。如何订阅?您可以问一个新问题解释您当前的问题,不在此问题标题的范围内。您好:Hareesh您能帮我澄清我的问题吗。在这种情况下如何显示多个图像。谢谢Hareesh,您的代码在多视图上工作。谢谢。
ngOnInit() {

    this.products = this.afs.collection('/products', ref => ref.where('publish', '==', true))   .snapshotChanges().map(actions => {
    return actions.map(a => {
      const data = a.payload.doc.data();
      const id = a.payload.doc.id;
      return this.afs.collection('users').doc(data.uid).snapshotChanges().map(userActions=>{
        return userActions.payload.data();
      }).map(user=>{
        return this.afs.collection('productPhotos').doc(id).snapshotChanges().map(photoActions=>{
            return photoActions.payload.data();
        }).map(res=>{
          return { id:id, url:res.url, displayName:user.displayName, email:user.email, ...data };
        })
      }).flatMap(merge => Observable.combineLatest(merge))
    });
    }).flatMap(merge => Observable.combineLatest(merge)).map(data => {
    return [].concat(...data).map(d => {
      return d;
   })
 })

}