Reputation: 7868
I'm working with firestore for the first time and the dataset in which I have users and games data.
In every game data I've finalScore
There is a foreign key in Games
called userID
for each game that differentiate that this game data belong to.
I want to write a function in index.js
which can take in the userID
and SUM all the finalScore
and return the total score for that user.
So far what I have after searching google is:
exports.myFunctionName = functions.firestore
.document('Users').onWrite((change, context) => {
// ... Your code here
});
This is the first time I'm working on this and want to achieve something for which I didn't find related help. I'm working on an iOS app for which I'm using this as a backend service.
Upvotes: 0
Views: 958
Reputation: 317427
Firestore doesn't have any aggregation queries, because they don't scale massively as Firestore requires. If you want to find a total value among documents, you will either have to:
Upvotes: 2