diff --git a/README.md b/README.md index 25dde49..89dbbb7 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ input: {payload: {path: 'foo/bar'}, {some: 'object', foo: 17}} Pushes the new object onto an array under the path input: {payload: {path: 'foo/bar'}, {some: 'object', foo: 17}} +output: the url to the newly pushed data () something like "https://xxxx-1111.firebaseio.com/foo/quux/-LhzUELu7Vv4DCD16zTK") ## rtdb-query Set up a reactive query for a path in the rtdb database. @@ -67,6 +68,7 @@ input: {payload: {path: 'foo/bar'}, {some: 'object', foo: 17}} Adds the new object under the collection the path describes and assigns it a random id input: {payload: {path: 'foo/bar'}, {some: 'object', foo: 17}} +output: The id of the new document ## firestore-query Set up a reactive query for a collection in the firestore database. diff --git a/firestore-add.html b/firestore-add.html index 152b98a..ef24a1e 100644 --- a/firestore-add.html +++ b/firestore-add.html @@ -8,7 +8,7 @@ cred: {value: "", type: 'firebase-config'} }, inputs:1, - outputs:0, + outputs:1, icon: "firebase-admin-icon.png", label: function() { return this.name||"firestore-add"; diff --git a/firestore-add.js b/firestore-add.js index 2b9407b..60bab72 100644 --- a/firestore-add.js +++ b/firestore-add.js @@ -18,8 +18,9 @@ module.exports = function(RED) { const obj = msg.payload.obj console.log('storing '+obj+' at rtdb path '+path) this.admin.firestore().collection(path).add(obj).then((res)=>{ - console.log('firestore set result '+res) + console.log('firestore set result '+res.id) console.dir(res) + node.send({payload:res.id}) }) } }.bind(this)); diff --git a/rtdb-push.html b/rtdb-push.html index ccbd294..666d6f1 100644 --- a/rtdb-push.html +++ b/rtdb-push.html @@ -8,7 +8,7 @@ cred: {value: "", type: 'firebase-config'} }, inputs:1, - outputs:0, + outputs:1, icon: "firebase-admin-icon.png", label: function() { return this.name||"rtdb-push"; @@ -46,5 +46,5 @@ \ No newline at end of file diff --git a/rtdb-push.js b/rtdb-push.js index 482e6a2..2f42dee 100644 --- a/rtdb-push.js +++ b/rtdb-push.js @@ -20,6 +20,7 @@ module.exports = function(RED) { this.admin.database().ref(path).push(obj).then((res)=>{ console.log('firebase set result '+res) console.dir(res) + node.send({payload: res}) }) } }.bind(this));