I have an SQL background and am trying to get my head around document storage. For a Firebase database structure as follows:
- John (doc)
- Restaurant Reviews (collection)
- Review 1 (doc)
- Review 2 (doc)
- Restaurant Reviews (collection)
- Paul (doc)
- Restaurant Reviews (collection)
- Review 3 (doc)
- Review 4 (doc)
- Restaurant Reviews (collection)
I'm using a CollectionGroup to get all reviews for a specific restaurant (the restaurant Id is on the review document). This works well. I also want to get some metadata about the user. I can achieve this with a secondary query when iterating over each review that was returned:
restaurantReviewsSnapshot.forEach(reviewSnap => {
reviewSnap.ref.parent.parent.get().then(reviewerSnap => {
...
However, this is not efficient. Is it possible to get this related data in some sort of a join operation in one go?