I've setup a simple onWrite
listener on documents in my sandbox
collection, just to test the listener API and see that I know how to use it.
Apparently I don't, because the following index.js
in my functions
dir:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.sandbox = functions.firestore.document('sandbox/{wildcard}')
.onWrite((change, context) => {
console.log("In")
console.log("Before is " + change.before)
console.log("Wildcard is " + context.params.wildcard)
return null
})
results in the following output (whenever I add / remove a field in my sandbox/yoohoo
document):
In
Before is undefined
TypeError: Cannot read property 'params' of undefined
What am I doing wrong?
onWrite(event)=>{ console.log(event.data.val())
– Peter Haddad"firebase-functions": "^0.9.0"
in my dependencies. Should I change it to"firebase-functions": "^1.0"
? – Dori