Skip to content

Commit 555f3c9

Browse files
committed
minor updates based on comments.
1 parent 18d4e05 commit 555f3c9

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

packages/firestore/src/local/indexeddb_document_overlay_cache.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache {
147147
): PersistencePromise<Map<DocumentKey, Overlay>> {
148148
const result = new Map<DocumentKey, Overlay>();
149149
let currentBatchId: number | undefined = undefined;
150-
let currentCount = 0;
151150
// We want batch IDs larger than `sinceBatchId`, and so the lower bound
152151
// is not inclusive.
153152
const range = IDBKeyRange.bound(
@@ -164,16 +163,15 @@ export class IndexedDbDocumentOverlayCache implements DocumentOverlayCache {
164163
(_, dbOverlay, control) => {
165164
// We do not want to return partial batch overlays, even if the size
166165
// of the result set exceeds the given `count` argument. Therefore, we
167-
// continue to aggregate the results even after `currentCount` exceeds
166+
// continue to aggregate results even after the result size exceeds
168167
// `count` if there are more overlays from the `currentBatchId`.
169168
const overlay = fromDbDocumentOverlay(this.serializer, dbOverlay);
170169
if (
171-
currentCount < count ||
170+
result.size < count ||
172171
overlay.largestBatchId === currentBatchId
173172
) {
174173
result.set(overlay.getKey(), overlay);
175174
currentBatchId = overlay.largestBatchId;
176-
++currentCount;
177175
} else {
178176
control.done();
179177
}

packages/firestore/src/local/memory_document_overlay_cache.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import { PersistenceTransaction } from './persistence_transaction';
3232
export class MemoryDocumentOverlayCache implements DocumentOverlayCache {
3333
// A map sorted by DocumentKey, whose value is a pair of the largest batch id
3434
// for the overlay and the overlay itself.
35-
3635
private overlays = new SortedMap<DocumentKey, Overlay>(
3736
DocumentKey.comparator
3837
);

packages/firestore/src/model/document_key.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export class DocumentKey {
5353

5454
/** Returns the collection group (i.e. the name of the parent collection) for this key. */
5555
getCollectionGroup(): string {
56+
debugAssert(
57+
!this.path.isEmpty(),
58+
'Cannot get collection group for empty key'
59+
);
5660
return this.path.get(this.path.length - 2);
5761
}
5862

0 commit comments

Comments
 (0)