fixed typo in rtdb get node and added auto setup for firestore and rtdb get
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
# node-red-contrib-firebase-admin
|
# 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
|
# Overview
|
||||||
The main difference of this module and all other firebase/store modules for node-red is
|
The main difference of this module and all other firebase/store modules for node-red is
|
||||||
|
|||||||
@ -12,6 +12,13 @@ module.exports = function(RED) {
|
|||||||
this.admin = c.admin
|
this.admin = c.admin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setup = ()=>{
|
||||||
|
if(unsub){
|
||||||
|
unsub()
|
||||||
|
}
|
||||||
|
this.admin.firestore().doc(path).onSnapshot(cb)
|
||||||
|
}
|
||||||
|
|
||||||
const cb = (res)=>{
|
const cb = (res)=>{
|
||||||
console.log('firestore get result '+res)
|
console.log('firestore get result '+res)
|
||||||
console.dir(res)
|
console.dir(res)
|
||||||
@ -23,14 +30,12 @@ module.exports = function(RED) {
|
|||||||
node.on('input', function(msg) {
|
node.on('input', function(msg) {
|
||||||
if(msg && msg.payload){
|
if(msg && msg.payload){
|
||||||
const path = msg.payload.path
|
const path = msg.payload.path
|
||||||
if(unsub){
|
setup()
|
||||||
unsub()
|
|
||||||
}
|
|
||||||
this.admin.firestore().doc(path).onSnapshot(cb)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
setup()
|
||||||
|
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("firestore-get", FirebaseAdmin);
|
RED.nodes.registerType("firestore-get", FirebaseAdmin);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-firebase-admin",
|
"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.",
|
"description": "A node-red module that wraps the server-side admin SDK of firebase, firestore, et.c.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-path"><i class="icon-tag"></i> Name</label>
|
<label for="node-input-path"><i class="icon-tag"></i> Path</label>
|
||||||
<input type="text" id="node-input-path" placeholder="Path">
|
<input type="text" id="node-input-path" placeholder="Path">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -47,6 +47,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
setUpListener(path)
|
||||||
|
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("rtdb-get", FirebaseAdmin);
|
RED.nodes.registerType("rtdb-get", FirebaseAdmin);
|
||||||
|
|||||||
Reference in New Issue
Block a user