diff --git a/functions/src/backfill.js b/functions/src/backfill.js index a2b0f7c..a3641be 100644 --- a/functions/src/backfill.js +++ b/functions/src/backfill.js @@ -61,17 +61,20 @@ module.exports = functions.firestore.document(config.typesenseBackfillTriggerDoc if (thisBatch.empty) { break; } - const currentDocumentsBatch = await Promise.all( - thisBatch.docs.map(async (doc) => { - const docPath = doc.ref.path; - const pathParams = utils.pathMatchesSelector(docPath, config.firestoreCollectionPath); - - if (!isGroupQuery || (isGroupQuery && pathParams !== null)) { - return await utils.typesenseDocumentFromSnapshot(doc, pathParams); - } else { - return null; - } - }).filter((doc) => doc !== null)); + const currentDocumentsBatch = ( + await Promise.all( + thisBatch.docs.map(async (doc) => { + const docPath = doc.ref.path; + const pathParams = utils.pathMatchesSelector(docPath, config.firestoreCollectionPath); + + if (!isGroupQuery || (isGroupQuery && pathParams !== null)) { + return await utils.typesenseDocumentFromSnapshot(doc, pathParams); + } else { + return null; + } + }), + ) + ).filter((doc) => doc !== null); lastDoc = thisBatch.docs.at(-1) ?? null; try {