'Firestore query based on parent document fields
Solution 1:[1]
As far as I can see, you can get all orders of a specific shop, by querying like this:
var ordersRef = db.collection("orders");
var query = ordersRef.where("shopId", "==", "someId");
To get the corresponding reviews, you have to create a new reference that points to the review subcollection and read all reviews, a case in which there is no need to add the shopId as property within the review document.
If you wanted to use a collection group query, to get all reviews of a specific shop, then you would have needed that:
var reviews = db.collectionGroup("review").where("shopId", "==", "someId");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

