diff --git a/README.md b/README.md index 3a38199..2875c10 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # node-red-contrib-firebase-admin -A node-red module that wraps the server-side admin SDK of firebase, firestore, et.c. +A node-red module that wraps the server-side admin SDK of firebase, firestore, cloud storage, et.c. # Overview The main difference of this module and all other firebase/store modules for node-red is diff --git a/firestore/firestore-get.js b/firestore/firestore-get.js index 07de54b..52d9845 100644 --- a/firestore/firestore-get.js +++ b/firestore/firestore-get.js @@ -12,6 +12,13 @@ module.exports = function(RED) { this.admin = c.admin } + const setup = ()=>{ + if(unsub){ + unsub() + } + this.admin.firestore().doc(path).onSnapshot(cb) + } + const cb = (res)=>{ console.log('firestore get result '+res) console.dir(res) @@ -23,14 +30,12 @@ module.exports = function(RED) { node.on('input', function(msg) { if(msg && msg.payload){ const path = msg.payload.path - if(unsub){ - unsub() - } - this.admin.firestore().doc(path).onSnapshot(cb) + setup() } }.bind(this)); + setup() } RED.nodes.registerType("firestore-get", FirebaseAdmin); diff --git a/package.json b/package.json index 90597d0..5db514e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-firebase-admin", - "version": "1.0.95", + "version": "1.1.0", "description": "A node-red module that wraps the server-side admin SDK of firebase, firestore, et.c.", "main": "index.js", "scripts": { diff --git a/rtdb/rtdb-get.html b/rtdb/rtdb-get.html index 989729b..b60be49 100644 --- a/rtdb/rtdb-get.html +++ b/rtdb/rtdb-get.html @@ -40,7 +40,7 @@