added on nodes for rtdb and firestore andmade nodes pass through msg objects with as little changes as possible
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
|
||||
|
||||
let msgin
|
||||
let unsub
|
||||
|
||||
module.exports = function(RED) {
|
||||
@ -16,7 +16,7 @@ module.exports = function(RED) {
|
||||
if(unsub){
|
||||
unsub()
|
||||
}
|
||||
this.admin.firestore().doc(path).onSnapshot(cb)
|
||||
this.admin.firestore().doc(path).get().then(cb)
|
||||
}
|
||||
|
||||
const cb = (res)=>{
|
||||
@ -24,11 +24,17 @@ module.exports = function(RED) {
|
||||
console.dir(res)
|
||||
let val = res.data()
|
||||
console.log('val='+val)
|
||||
node.send({payload:val})
|
||||
if(msgin){
|
||||
msgin.payload = val
|
||||
node.send(msgin)
|
||||
} else {
|
||||
node.send({payload: val})
|
||||
}
|
||||
}
|
||||
|
||||
node.on('input', function(msg) {
|
||||
if(msg && msg.payload){
|
||||
msgin = msg
|
||||
const path = msg.payload.path
|
||||
setup(path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user