Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

docs(cloud_firestore): Aggregation queries sum example uses incorrect method #43

Description

@CaduRomaniello

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:

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions