Skip to content

Commit 88fa484

Browse files
committed
Address PR feedback.
1 parent 49779e5 commit 88fa484

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

packages/firestore/src/remote/datastore.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,25 +245,20 @@ export async function invokeRunAggregationQueryRpc(
245245
aggregates: Aggregate[]
246246
): Promise<ApiClientObjectMap<Value>> {
247247
const datastoreImpl = debugCast(datastore, DatastoreImpl);
248-
const wrapper = toRunAggregationQueryRequest(
248+
const { request, aliasMap } = toRunAggregationQueryRequest(
249249
datastoreImpl.serializer,
250250
queryToTarget(query),
251251
aggregates
252252
);
253253

254-
const parent = wrapper.request.parent;
254+
const parent = request.parent;
255255
if (!datastoreImpl.connection.shouldResourcePathBeIncludedInRequest) {
256-
delete wrapper.request.parent;
256+
delete request.parent;
257257
}
258258
const response = await datastoreImpl.invokeStreamingRPC<
259259
ProtoRunAggregationQueryRequest,
260260
ProtoRunAggregationQueryResponse
261-
>(
262-
'RunAggregationQuery',
263-
parent!,
264-
wrapper.request,
265-
/*expectedResponseCount=*/ 1
266-
);
261+
>('RunAggregationQuery', parent!, request, /*expectedResponseCount=*/ 1);
267262

268263
// Omit RunAggregationQueryResponse that only contain readTimes.
269264
const filteredResult = response.filter(proto => !!proto.result);
@@ -289,10 +284,10 @@ export async function invokeRunAggregationQueryRpc(
289284
ApiClientObjectMap<Value>
290285
>((accumulator, key) => {
291286
debugAssert(
292-
!isNullOrUndefined(wrapper.aliasMap[key]),
287+
!isNullOrUndefined(aliasMap[key]),
293288
`'${key}' not present in aliasMap result`
294289
);
295-
accumulator[wrapper.aliasMap[key]] = unmappedAggregateFields[key]!;
290+
accumulator[aliasMap[key]] = unmappedAggregateFields[key]!;
296291
return accumulator;
297292
}, {});
298293

packages/firestore/src/remote/serializer.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -887,16 +887,14 @@ export function toQueryTarget(
887887
return result;
888888
}
889889

890-
export interface RunAggregationQueryRequestWrapper {
891-
request: ProtoRunAggregationQueryRequest;
892-
aliasMap: Record<string, string>;
893-
}
894-
895890
export function toRunAggregationQueryRequest(
896891
serializer: JsonProtoSerializer,
897892
target: Target,
898893
aggregates: Aggregate[]
899-
): RunAggregationQueryRequestWrapper {
894+
): {
895+
request: ProtoRunAggregationQueryRequest;
896+
aliasMap: Record<string, string>;
897+
} {
900898
const queryTarget = toQueryTarget(serializer, target);
901899
const aliasMap: Record<string, string> = {};
902900

0 commit comments

Comments
 (0)