How can to join 3 firestore collection together, the answer as below ngOnInit() {
// this.productService.getImageUrl().subscribe(products=> this.products = products)
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;
//this.afs.collection('productPhotos').doc(id)
return this.afs.collection('users').doc(data.uid).snapshotChanges().map(userActions=>{
return userActions.payload.data();
}).map(user=>{
// return { id:id, url:user.url, ...data };
return { id:id, displayName:user.displayName, email:user.email, ...data };
})
});
}).flatMap(merge => Observable.combineLatest(merge)).map(data => {
return [].concat(...data).map(d => {
return d;
})
})
}