Skip to content

Commit ee14b2d

Browse files
committed
Fixes and cleanup.
1 parent f1fbe90 commit ee14b2d

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

common/api-review/firestore-lite.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type AddPrefixToKeys<Prefix extends string, T extends Record<string, unkn
1919

2020
// @public
2121
export class AggregateField<R> {
22-
constructor(aggregateType: AggregateType, methodName: string, field?: string | FieldPath);
22+
constructor(aggregateType?: AggregateType, methodName?: string, field?: string | FieldPath);
2323
// (undocumented)
2424
readonly aggregateType: AggregateType;
2525
readonly type = "AggregateField";
@@ -50,7 +50,7 @@ export type AggregateSpecData<T extends AggregateSpec> = {
5050
};
5151

5252
// @public
53-
export type AggregateType = 'avg' | 'count' | 'sum';
53+
export type AggregateType = 'count' | 'avg' | 'sum';
5454

5555
// @public
5656
export function arrayRemove(...elements: unknown[]): FieldValue;

common/api-review/firestore.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type AddPrefixToKeys<Prefix extends string, T extends Record<string, unkn
1919

2020
// @public
2121
export class AggregateField<R> {
22-
constructor(aggregateType: AggregateType, methodName: string, field?: string | FieldPath);
22+
constructor(aggregateType?: AggregateType, methodName?: string, field?: string | FieldPath);
2323
// (undocumented)
2424
readonly aggregateType: AggregateType;
2525
readonly type = "AggregateField";
@@ -50,7 +50,7 @@ export type AggregateSpecData<T extends AggregateSpec> = {
5050
};
5151

5252
// @public
53-
export type AggregateType = 'avg' | 'count' | 'sum';
53+
export type AggregateType = 'count' | 'avg' | 'sum';
5454

5555
// @public
5656
export function arrayRemove(...elements: unknown[]): FieldValue;

packages/firestore/src/api/aggregate.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { AggregateSpec, Query } from '../api';
18+
import { AggregateField, AggregateSpec, Query } from '../api';
1919
import { AggregateImpl } from '../core/aggregate';
2020
import { firestoreClientRunAggregateQuery } from '../core/firestore_client';
2121
import { count } from '../lite-api/aggregate';
22-
import {
23-
AggregateQuerySnapshot,
24-
CountAggregateSpec
25-
} from '../lite-api/aggregate_types';
22+
import { AggregateQuerySnapshot } from '../lite-api/aggregate_types';
2623
import { ObjectValue } from '../model/object_value';
2724
import { cast } from '../util/input_validation';
2825
import { mapToArray } from '../util/obj';
@@ -60,8 +57,8 @@ export {
6057
*/
6158
export function getCountFromServer(
6259
query: Query<unknown>
63-
): Promise<AggregateQuerySnapshot<CountAggregateSpec>> {
64-
const countQuerySpec: CountAggregateSpec = {
60+
): Promise<AggregateQuerySnapshot<{ count: AggregateField<number> }>> {
61+
const countQuerySpec: { count: AggregateField<number> } = {
6562
count: count()
6663
};
6764

packages/firestore/src/lite-api/aggregate.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import { mapToArray } from '../util/obj';
2626
import {
2727
AggregateField,
2828
AggregateQuerySnapshot,
29-
AggregateSpec,
30-
CountAggregateSpec
29+
AggregateSpec
3130
} from './aggregate_types';
3231
import { getDatastore } from './components';
3332
import { Firestore } from './database';
@@ -51,8 +50,8 @@ import { LiteUserDataWriter } from './reference_impl';
5150
*/
5251
export function getCount(
5352
query: Query<unknown>
54-
): Promise<AggregateQuerySnapshot<CountAggregateSpec>> {
55-
const countQuerySpec: CountAggregateSpec = {
53+
): Promise<AggregateQuerySnapshot<{ count: AggregateField<number> }>> {
54+
const countQuerySpec: { count: AggregateField<number> } = {
5655
count: count()
5756
};
5857

packages/firestore/src/lite-api/aggregate_types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ export interface AggregateSpec {
7676
[field: string]: AggregateFieldType;
7777
}
7878

79-
/**
80-
* Helper AggregateSpec for count.
81-
* @internal
82-
*/
83-
export interface CountAggregateSpec { count: AggregateField<number> }
84-
8579
/**
8680
* A type whose keys are taken from an `AggregateSpec`, and whose values are the
8781
* result of the aggregation performed by the corresponding `AggregateField`

0 commit comments

Comments
 (0)