Skip to content

Commit cc7d351

Browse files
committed
indexeddb_remote_document_cache.ts: switch from loadAll() to iterate() in preparation for using documentType index
1 parent 06ab5c4 commit cc7d351

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/firestore/src/local/indexeddb_remote_document_cache.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,13 @@ class IndexedDbRemoteDocumentCacheImpl implements IndexedDbRemoteDocumentCache {
299299
''
300300
];
301301

302+
let results = mutableDocumentMap();
303+
302304
return remoteDocumentsStore(transaction)
303-
.loadAll(IDBKeyRange.bound(startKey, endKey, true))
304-
.next(dbRemoteDocs => {
305-
context?.incrementDocumentReadCount(dbRemoteDocs.length);
306-
let results = mutableDocumentMap();
307-
for (const dbRemoteDoc of dbRemoteDocs) {
305+
.iterate(
306+
{ range: IDBKeyRange.bound(startKey, endKey, true) },
307+
(_, dbRemoteDoc, control) => {
308+
context?.incrementDocumentReadCount(1);
308309
const document = this.maybeDecodeDocument(
309310
DocumentKey.fromSegments(
310311
dbRemoteDoc.prefixPath.concat(
@@ -322,8 +323,8 @@ class IndexedDbRemoteDocumentCacheImpl implements IndexedDbRemoteDocumentCache {
322323
results = results.insert(document.key, document);
323324
}
324325
}
325-
return results;
326-
});
326+
)
327+
.next(() => results);
327328
}
328329

329330
getAllFromCollectionGroup(

0 commit comments

Comments
 (0)