Skip to content

Commit d5ed275

Browse files
petterw03samtstern
authored andcommitted
Fix getting the object properties (#45)
1 parent cd2e095 commit d5ed275

File tree

1 file changed

+2
-2
lines changed
  • firestore/solution-aggregation/functions

1 file changed

+2
-2
lines changed

firestore/solution-aggregation/functions/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ exports.aggregateRatings = functions.firestore
2121
return db.runTransaction(transaction => {
2222
return transaction.get(restRef).then(restDoc => {
2323
// Compute new number of ratings
24-
var newNumRatings = restDoc.data('numRatings') + 1;
24+
var newNumRatings = restDoc.data().numRatings + 1;
2525

2626
// Compute new average rating
27-
var oldRatingTotal = restDoc.data('avgRating') * restDoc.data('numRatings');
27+
var oldRatingTotal = restDoc.data().avgRating * restDoc.data().numRatings;
2828
var newAvgRating = (oldRatingTotal + ratingVal) / newNumRatings;
2929

3030
// Update restaurant info

0 commit comments

Comments
 (0)