We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd2e095 commit d5ed275Copy full SHA for d5ed275
firestore/solution-aggregation/functions/index.js
@@ -21,10 +21,10 @@ exports.aggregateRatings = functions.firestore
21
return db.runTransaction(transaction => {
22
return transaction.get(restRef).then(restDoc => {
23
// Compute new number of ratings
24
- var newNumRatings = restDoc.data('numRatings') + 1;
+ var newNumRatings = restDoc.data().numRatings + 1;
25
26
// Compute new average rating
27
- var oldRatingTotal = restDoc.data('avgRating') * restDoc.data('numRatings');
+ var oldRatingTotal = restDoc.data().avgRating * restDoc.data().numRatings;
28
var newAvgRating = (oldRatingTotal + ratingVal) / newNumRatings;
29
30
// Update restaurant info
0 commit comments