I have the following "schema" in Google Firestore. I have a lists
collection with different lists and in the lists I have another collection called people
.
/COLLECTION_1/ID/COLLECTION_2/ID
/lists/1/people/1
When I get the list document with ID 1, I want to get the count of the people in that list. Like I want to know how many people documents are in the collection for the list with ID 1.
What I don't want:
- I don't want to fetch all the people and count them in the frontend because I have a lot of lists in my overview and this would be much useless traffic.
- I don't want to manually calculate the count in the "frontend" and send it on add or update.
Is this possible with Firestore? Are there anything like a view or populated query, or something like aggregations (from mongodb)?