Skip to content

Commit 31cd181

Browse files
committed
for.of instead of foreach
1 parent e8811ac commit 31cd181

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

infra/dataform-export/firestore.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,22 @@ export class FirestoreBatch {
8383
}
8484

8585
while (true) {
86-
const snapshot = await collectionQuery.limit(100000).get()
86+
const snapshot = await collectionQuery.limit(this.batchSize * this.maxConcurrentBatches).get()
8787
if (snapshot.empty) {
8888
break
8989
}
9090

91-
snapshot.forEach(async (doc) => {
91+
for await (const doc of snapshot.docs) {
9292
this.currentBatch.push(doc)
9393

9494
if (this.currentBatch.length >= this.batchSize) {
9595
this.queueBatch('delete')
9696
}
97-
9897
if (this.batchPromises.length >= this.maxConcurrentBatches) {
9998
await this.commitBatches()
10099
}
101100
totalDocsDeleted++
102-
})
101+
}
103102
}
104103
await this.finalFlush('delete')
105104

0 commit comments

Comments
 (0)