@@ -19,11 +19,15 @@ export type AddPrefixToKeys<Prefix extends string, T extends Record<string, unkn
19
19
20
20
// @public
21
21
export class AggregateField <T > {
22
+ readonly aggregateType: AggregateType ;
22
23
readonly type = " AggregateField" ;
23
24
}
24
25
25
26
// @public
26
- export type AggregateFieldType = AggregateField <number | null >;
27
+ export function aggregateFieldEqual(left : AggregateField <unknown >, right : AggregateField <unknown >): boolean ;
28
+
29
+ // @public
30
+ export type AggregateFieldType = ReturnType <typeof sum > | ReturnType <typeof average > | ReturnType <typeof count >;
27
31
28
32
// @public
29
33
export class AggregateQuerySnapshot <AggregateSpecType extends AggregateSpec , AppModelType = DocumentData , DbModelType extends DocumentData = DocumentData > {
@@ -46,6 +50,9 @@ export type AggregateSpecData<T extends AggregateSpec> = {
46
50
[P in keyof T ]: T [P ] extends AggregateField <infer U > ? U : never ;
47
51
};
48
52
53
+ // @public
54
+ export type AggregateType = ' count' | ' avg' | ' sum' ;
55
+
49
56
// @public
50
57
export function and(... queryConstraints : QueryFilterConstraint []): QueryCompositeFilterConstraint ;
51
58
@@ -55,6 +62,9 @@ export function arrayRemove(...elements: unknown[]): FieldValue;
55
62
// @public
56
63
export function arrayUnion(... elements : unknown []): FieldValue ;
57
64
65
+ // @public
66
+ export function average(field : string | FieldPath ): AggregateField <number | null >;
67
+
58
68
// @public
59
69
export class Bytes {
60
70
static fromBase64String(base64 : string ): Bytes ;
@@ -95,6 +105,9 @@ export function connectFirestoreEmulator(firestore: Firestore, host: string, por
95
105
mockUserToken? : EmulatorMockTokenOptions | string ;
96
106
}): void ;
97
107
108
+ // @public
109
+ export function count(): AggregateField <number >;
110
+
98
111
// @public
99
112
export function deleteDoc<AppModelType , DbModelType extends DocumentData >(reference : DocumentReference <AppModelType , DbModelType >): Promise <void >;
100
113
@@ -201,6 +214,9 @@ export class GeoPoint {
201
214
};
202
215
}
203
216
217
+ // @public
218
+ export function getAggregate<AggregateSpecType extends AggregateSpec , AppModelType , DbModelType extends DocumentData >(query : Query <AppModelType , DbModelType >, aggregateSpec : AggregateSpecType ): Promise <AggregateQuerySnapshot <AggregateSpecType , AppModelType , DbModelType >>;
219
+
204
220
// @public
205
221
export function getCount<AppModelType , DbModelType extends DocumentData >(query : Query <AppModelType , DbModelType >): Promise <AggregateQuerySnapshot <{
206
222
count: AggregateField <number >;
@@ -388,6 +404,9 @@ export function startAt<AppModelType, DbModelType extends DocumentData>(snapshot
388
404
// @public
389
405
export function startAt(... fieldValues : unknown []): QueryStartAtConstraint ;
390
406
407
+ // @public
408
+ export function sum(field : string | FieldPath ): AggregateField <number >;
409
+
391
410
// @public
392
411
export function terminate(firestore : Firestore ): Promise <void >;
393
412
0 commit comments