I would like a function to get executed everytime a new user is added to a matchmaking object, to increase the number of matchmaking users.
exports.onCreateMatchmakingUser = functions.database.ref('/matchmaking/{$uid}').onCreate((snapshot, context) => {
const currentMatchmakingAmount = snapshot.ref.parent.child('matchmakingAmount').val();
return snapshot.ref.parent.update({matchmakingAmount: currentMatchmakingAmount+1});
});
I don't want to fetch the whole matchmaking object and then fetch the number, I just want the matchmakingAmount. Does snapshot.ref.parent
make this a problem (does it fetch the whole matchmaking object, or just the reference to it without downloading its data)? And if it does, how can I solve this problem and write another function that just updates the number without unnecessary downloads?