I have created a database using Google Firestore. I need to get all Documents in the Collection as well as the Sub-Collection for each Document in one response.
So, let's say I have a Stores Collections with a set of Documents. Each Document has a Sub-Collection called Reviews. so my Firestore path would be like this: /stores/storeID/reviews/reviewID
I can retrieve all Store Documents and Reviews individually, but I want to combine the response for the Documents and Sub-Collections into one response.
I have tried doing this:
this.firestoreService
.colWithIds$('restaurants')
.switchMap(restaurants => {
const res = restaurants.map(restaurant => {
return this.firestoreService
.col$(`restaurants/${r.id}/ratings`)
.map(ratings => Object.assign(restaurant, {ratings}));
});
return Observable.combineLatest(...res);
})
.subscribe(restaurants => console.log(restaurants);
For reference, I am using these helpers: AngularFirebase中 上面显示的代码文章可以在here.
中找到我曾尝试实现上述代码,但似乎无法使其正常工作。
在此方面的任何帮助将不胜感激。
如果您需要我的更多信息,请告诉我。
该问题被标记为重复问题,但我不认为其他问题可以提供任何真实答案。如果有人对我的问题有真正的答案,请在评论部分中提供。