Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Add Aggregate method to QueryInternal
  • Loading branch information
KKimj committed Apr 1, 2025
commit c83c27b4190b1c93bf67f45c360dadd3d8abd1c7
7 changes: 7 additions & 0 deletions firestore/src/android/query_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ AggregateQuery QueryInternal::Count() const {
return firestore_->NewAggregateQuery(env, aggregate_query);
}

AggregateQuery QueryInternal::Aggregate(const FieldPath& field) const {
Env env = GetEnv();
Local<Object> java_field = FieldPathConverter::Create(env, field);
Local<Object> aggregate_query = env.Call(obj_, kAggregate, java_field);
return firestore_->NewAggregateQuery(env, aggregate_query);
}

Query QueryInternal::Where(const firebase::firestore::Filter& filter) const {
Env env = GetEnv();
Local<Object> query = env.Call(obj_, kWhere, filter.internal_->ToJava());
Expand Down
9 changes: 9 additions & 0 deletions firestore/src/android/query_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class QueryInternal : public Wrapper {
*/
virtual AggregateQuery Count() const;

/**
* @brief Returns a query that calculates the specified aggregation over the
* documents in the result set of this query.
*
* @param[in] aggregate_field The aggregation field.
* @return An aggregate query that performs the specified aggregation.
*/
virtual AggregateQuery Aggregate(const AggregateField& aggregate_field) const;

/**
* @brief Creates and returns a new Query with the additional filter.
*
Expand Down