Skip to content

Commit

Permalink
Use action: upsert for backfill
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbosco committed Jan 2, 2025
1 parent 5715012 commit ef8378a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion functions/src/backfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = functions.firestore.document(config.typesenseBackfillTriggerDoc

lastDoc = thisBatch.docs.at(-1) ?? null;
try {
await typesense.collections(encodeURIComponent(config.typesenseCollectionName)).documents().import(currentDocumentsBatch);
await typesense.collections(encodeURIComponent(config.typesenseCollectionName)).documents().import(currentDocumentsBatch, { action: 'upsert' });

Check failure on line 81 in functions/src/backfill.js

View workflow job for this annotation

GitHub Actions / build_and_test

There should be no space after '{'

Check failure on line 81 in functions/src/backfill.js

View workflow job for this annotation

GitHub Actions / build_and_test

Strings must use doublequote

Check failure on line 81 in functions/src/backfill.js

View workflow job for this annotation

GitHub Actions / build_and_test

There should be no space before '}'
functions.logger.info(`Imported ${currentDocumentsBatch.length} documents into Typesense`);
} catch (error) {
functions.logger.error(`Import error in a batch of documents from ${currentDocumentsBatch[0].id} to ${lastDoc.id}`, error);
Expand Down

0 comments on commit ef8378a

Please sign in to comment.