Skip to content

Commit e1198da

Browse files
Firestore Firebase - parse boolean values in Update Document & Create Document (#11801)
* parse boolean values * versions * Remove 0 and 1 case for boolean * Fix typos --------- Co-authored-by: Leo Vu <vunguyenhung@outlook.com> Co-authored-by: Leo Vu <18277920+vunguyenhung@users.noreply.github.com>
1 parent 18b47d5 commit e1198da

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

components/firebase_admin_sdk/actions/common/base.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ export default {
1010
],
1111
},
1212
},
13+
methods: {
14+
parseBooleanValues(data) {
15+
Object.entries(data).forEach(([
16+
key,
17+
value,
18+
]) => {
19+
data[key] = value === "false"
20+
? false
21+
: value === "true"
22+
? true
23+
: value;
24+
});
25+
return data;
26+
},
27+
},
1328
async run({ $ }) {
1429
try {
1530
await this.firebase.initializeApp(this.databaseRegion);

components/firebase_admin_sdk/actions/create-document/create-document.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export default {
44
...common,
55
key: "firebase_admin_sdk-create-document",
66
name: "Create Document",
7-
description: "Creates a New Document. [See the docs here](https://googleapis.dev/nodejs/firestore/latest/CollectionReference.html#add)",
8-
version: "0.0.7",
7+
description: "Creates a New Document. [See the documentation](https://googleapis.dev/nodejs/firestore/latest/CollectionReference.html#add)",
8+
version: "0.0.8",
99
type: "action",
1010
props: {
1111
...common.props,
@@ -34,7 +34,8 @@ export default {
3434
methods: {
3535
...common.methods,
3636
async getResponse() {
37-
return this.firebase.createDocument(this.collection, this.data, this.customId);
37+
const data = this.parseBooleanValues(this.data);
38+
return this.firebase.createDocument(this.collection, data, this.customId);
3839
},
3940
emitSummary($, response) {
4041
$.export("$summary", `Successfully added document ${response?._path?.segments[1] ?? ""}`);

components/firebase_admin_sdk/actions/create-realtime-db-record/create-realtime-db-record.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "firebase_admin_sdk-create-realtime-db-record",
66
name: "Create Firebase Realtime Database Record",
77
description: "Creates or replaces a child object within your Firebase Realtime Database. [See the docs here](https://firebase.google.com/docs/reference/js/database#update)",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "action",
1010
props: {
1111
...common.props,

components/firebase_admin_sdk/actions/list-documents/list-documents.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "firebase_admin_sdk-list-documents",
66
name: "List Documents",
77
description: "Lists documents in a collection. [See the docs here](https://googleapis.dev/nodejs/firestore/latest/CollectionReference.html#listDocuments)",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "action",
1010
props: {
1111
...common.props,

components/firebase_admin_sdk/actions/update-document/update-document.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import common from "../common/base.mjs";
33
export default {
44
...common,
55
key: "firebase_admin_sdk-update-document",
6-
name: "Update Documents",
7-
description: "Updates a Document. [See the docs here](https://googleapis.dev/nodejs/firestore/latest/DocumentReference.html#update)",
8-
version: "0.0.4",
6+
name: "Update Document",
7+
description: "Updates a Document. [See the documentation](https://googleapis.dev/nodejs/firestore/latest/DocumentReference.html#update)",
8+
version: "0.0.5",
99
type: "action",
1010
props: {
1111
...common.props,
@@ -39,7 +39,8 @@ export default {
3939
methods: {
4040
...common.methods,
4141
async getResponse() {
42-
return this.firebase.updateDocument(this.collection, this.document, this.data);
42+
const data = this.parseBooleanValues(this.data);
43+
return this.firebase.updateDocument(this.collection, this.document, data);
4344
},
4445
emitSummary($) {
4546
$.export("$summary", `Successfully updated document ${this.document}`);

components/firebase_admin_sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/firebase_admin_sdk",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"description": "Pipedream Firebase Admin SDK Components",
55
"main": "firebase_admin_sdk.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)