Skip to content

Commit 4af2aa6

Browse files
committed
feat(firestore-bigquery-export): ignore document deletion
1 parent 3990751 commit 4af2aa6

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

firestore-bigquery-export/extension.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,21 @@ params:
647647
default: info
648648
required: true
649649

650+
- param: IGNORE_DOCUMENT_DELETION
651+
label: Ignore Document Deletion
652+
description: >-
653+
If enabled, Firestore deleted document will not be exported (the Firestore
654+
onDocumentDeleted event will be ignored). The reduction in data should be
655+
more performant, and avoid potential resource limitations.
656+
type: select
657+
required: false
658+
default: no
659+
options:
660+
- label: Yes
661+
value: yes
662+
- label: No
663+
value: no
664+
650665
events:
651666
# OLD event types for backward compatibility
652667
- type: firebase.extensions.firestore-counter.v1.onStart

firestore-bigquery-export/functions/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,5 @@ export default {
7777
process.env.BACKUP_GCS_BUCKET || `${process.env.PROJECT_ID}.appspot.com`,
7878
backupDir: `_${process.env.INSTANCE_ID || "firestore-bigquery-export"}`,
7979
logLevel: process.env.LOG_LEVEL || LogLevel.INFO,
80+
ignoreDocumentDeletion: process.env.IGNORE_DOCUMENT_DELETION === "yes" ? true : false,
8081
};

firestore-bigquery-export/functions/src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,16 @@ export const fsexportbigquery = onDocumentWritten(
173173
const fullResourceName = `projects/${projectId}/databases/${config.databaseId}/documents/${relativeName}`;
174174
const eventId = context.id;
175175
const operation = changeType;
176-
176+
177+
if (config.ignoreDocumentDeletion && isDeleted) {
178+
logs.logEventAction(
179+
"Firestore event received and ignored by onDocumentWritten trigger",
180+
fullResourceName,
181+
eventId,
182+
operation
183+
);
184+
return;
185+
}
177186
logs.logEventAction(
178187
"Firestore event received by onDocumentWritten trigger",
179188
fullResourceName,

0 commit comments

Comments
 (0)