Skip to content

Aggregation Queries #230

Description

@anisrfd

Do fireO only supports count and not other aggregation like sum, avg?

Here's example code using firestore library:

`
from google.cloud import firestore
from google.cloud.firestore_v1 import aggregation
from google.cloud.firestore_v1.base_query import FieldFilter

def create_count_query(project_id: str) -> None:

client = firestore.Client(project=project_id)
collection_ref = client.collection("users")
query = collection_ref.where(filter=FieldFilter("born", ">", 1800))
aggregate_query = aggregation.AggregationQuery(query)

# `alias` to provides a key for accessing the aggregate query results
aggregate_query.count(alias="all")

results = aggregate_query.get()
for result in results:
    print(f"Alias of results from query: {result[0].alias}")
    print(f"Number of results from query: {result[0].value}")

`

I want to do the samething using the fireO library. Is it possible?

Thank you.

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