Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c83c27b

Browse files
committedApr 1, 2025
feat: Add Aggregate method to QueryInternal
1 parent 2d2ecf2 commit c83c27b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎firestore/src/android/query_android.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ AggregateQuery QueryInternal::Count() const {
162162
return firestore_->NewAggregateQuery(env, aggregate_query);
163163
}
164164

165+
AggregateQuery QueryInternal::Aggregate(const FieldPath& field) const {
166+
Env env = GetEnv();
167+
Local<Object> java_field = FieldPathConverter::Create(env, field);
168+
Local<Object> aggregate_query = env.Call(obj_, kAggregate, java_field);
169+
return firestore_->NewAggregateQuery(env, aggregate_query);
170+
}
171+
165172
Query QueryInternal::Where(const firebase::firestore::Filter& filter) const {
166173
Env env = GetEnv();
167174
Local<Object> query = env.Call(obj_, kWhere, filter.internal_->ToJava());

‎firestore/src/android/query_android.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ class QueryInternal : public Wrapper {
7171
*/
7272
virtual AggregateQuery Count() const;
7373

74+
/**
75+
* @brief Returns a query that calculates the specified aggregation over the
76+
* documents in the result set of this query.
77+
*
78+
* @param[in] aggregate_field The aggregation field.
79+
* @return An aggregate query that performs the specified aggregation.
80+
*/
81+
virtual AggregateQuery Aggregate(const AggregateField& aggregate_field) const;
82+
7483
/**
7584
* @brief Creates and returns a new Query with the additional filter.
7685
*

0 commit comments

Comments
 (0)
Please sign in to comment.