-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Description for the Issue
Hi, Firebase team!
I've identified a small documentation bug that could be confusing to other developers. In the "Use the sum()
aggregation" section of the aggregation queries documentation, the example code for the sum aggregation is calling the getAverage()
method instead of getSum()
.
Reference:
- Page: https://firebase.google.com/docs/firestore/query-data/aggregation-queries
- Section: "Use the
sum()
aggregation"
Incorrect code
db.collection("cities").aggregate(sum("population")).get().then(
(res) => print(res.getAverage("population")),
onError: (e) => print("Error completing: $e"),
);
Correct code
For the example to work as expected, the method call should be res.getSum("population")
.
Suggested Correct Code:
db.collection("cities").aggregate(sum("population")).get().then(
(res) => print(res.getSum("population")),
onError: (e) => print("Error completing: $e"),
);
It also occurs in the second example of this section where it shows that sum()
aggregation considers all filters in the query and any limit clauses. It's worth to mention that i only saw this inconsistency in the dart/flutter example.
Thanks!
Metadata
Metadata
Assignees
Labels
No labels