I want to use onCreate method instead of onWrite for the sake of efficiency but I face that error:
functions.database.ref(...).onCreate is not a function.
However, there seems to be a function as mentioned in the doc https://firebase.google.com/docs/reference/functions/functions.database.RefBuilder#onCreate
My code starts as follows:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.manager = functions.database.ref('some_ref')
.onCreate(event =>{
I am looking forward to your helps.
Thanks in advance.
With Cloud Functions you write simple, single-purpose functions that are attached to events emitted from your cloud infrastructure and services. Your Cloud Function is triggered when an event being watched is fired.
Update: In a comment on the question, Firebaser Doug Stevenson indicates that running npm upgrade
in the project's functions folder is the simpler way to update to the latest version.
I don't find any documentation for how to update to the latest version of firebase-functions
. Following the general guidelines described here, go to your project's functions directory and enter this command:
npm install --save firebase-functions
You can then look in the package.json
file to see the versions installed. The new version of firebase-functions
that contains the new triggers is 0.5.9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With