Skip to content

Commit c2b9352

Browse files
committed
Add TABLE_ID parameter
1 parent e3e3239 commit c2b9352

File tree

5 files changed

+34
-8
lines changed

5 files changed

+34
-8
lines changed

firestore-bigquery-export/extension.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ params:
8686
label: Collection path
8787
description: >-
8888
What is the path of the the collection that you would like to export?
89-
default: extensions
90-
example: extensions
89+
default: users/{uid}/extensions
90+
example: users/{uid}/extensions
9191
validationRegex: "^[^/]+(/[^/]+/[^/]+)*$"
9292
validationErrorMessage: Must be a valid Cloud Firestore collection
9393
required: true
@@ -98,10 +98,24 @@ params:
9898
description: >-
9999
What ID would you like to use for your BigQuery dataset? This
100100
extension will create the dataset, if it doesn't already exist.
101-
validationRegex: ^[a-zA-Z0-9_]+$
101+
validationRegex: "^[a-zA-Z0-9_]+$"
102102
validationErrorMessage: >
103-
Dataset IDs must be alphanumeric (plus underscores) and must be no more than
103+
BigQuery dataset IDs must be alphanumeric (plus underscores) and must be no more than
104104
1024 characters.
105-
default: exported_collection
106-
example: exported_collection
105+
default: exported_dataset
106+
example: exported_dataset
107+
required: true
108+
109+
- param: TABLE_ID
110+
type: string
111+
label: Table ID
112+
description: >-
113+
What ID would you like to use for your BigQuery table inside that dataset? This
114+
extension will create the table, if it doesn't already exist.
115+
validationRegex: "^[a-zA-Z0-9_]+$"
116+
validationErrorMessage: >
117+
BigQuery table IDs must be alphanumeric (plus underscores) and must be no more than
118+
1024 characters.
119+
default: exported_table
120+
example: exported_table
107121
required: true

firestore-bigquery-export/functions/lib/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
1818
exports.default = {
1919
collectionPath: process.env.COLLECTION_PATH,
2020
datasetId: process.env.DATASET_ID,
21+
tableId: process.env.TABLE_ID,
2122
location: process.env.LOCATION,
2223
initialized: false
2324
};

firestore-bigquery-export/functions/lib/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ const functions = require("firebase-functions");
2929
const firestore_bigquery_change_tracker_1 = require("@firebaseextensions/firestore-bigquery-change-tracker");
3030
const logs = require("./logs");
3131
const util_1 = require("./util");
32-
const eventTracker = new firestore_bigquery_change_tracker_1.FirestoreBigQueryEventHistoryTracker(config_1.default);
32+
const eventTracker = new firestore_bigquery_change_tracker_1.FirestoreBigQueryEventHistoryTracker({
33+
collectionPath: config_1.default.tableId,
34+
datasetId: config_1.default.datasetId,
35+
initialized: false,
36+
suppressWarnings: false,
37+
});
3338
logs.init();
3439
exports.fsexportbigquery = functions.handler.firestore.document.onWrite((change, context) => __awaiter(void 0, void 0, void 0, function* () {
3540
logs.start();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
export default {
1818
collectionPath: process.env.COLLECTION_PATH,
1919
datasetId: process.env.DATASET_ID,
20+
tableId: process.env.TABLE_ID,
2021
location: process.env.LOCATION,
2122
initialized: false
2223
};

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ import {
2424
import * as logs from "./logs";
2525
import { getChangeType } from "./util";
2626

27-
const eventTracker: FirestoreEventHistoryTracker = new FirestoreBigQueryEventHistoryTracker(config);
27+
const eventTracker: FirestoreEventHistoryTracker = new FirestoreBigQueryEventHistoryTracker({
28+
collectionPath: config.tableId,
29+
datasetId: config.datasetId,
30+
initialized: false, // TODO: Remove this config.
31+
suppressWarnings: false, // TODO: Remove this config.
32+
});
2833

2934
logs.init();
3035

0 commit comments

Comments
 (0)