Reputation: 4854
I'm building an app to keep track of locations
and checkins
. Users check in during the day to different locations, and I want to keep a realtime overview over the number of users in each location.
I save check-in's in one collection and the locations in another.
I want to add a field to the location object that is calculated based on how many users are currently checked in to the location. Is there a way to do this on the db side, or would I have to create a new query for each of the locations?
Upvotes: 2
Views: 1652
Reputation: 13033
Use Cloud Functions and transactions.
Upvotes: 2