Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Functions Database Trigger 'onCreate is not a function'

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.

like image 513
Ziya ERKOC Avatar asked Jul 09 '17 11:07

Ziya ERKOC


People also ask

Which type of trigger is bound while creating cloud function in the lab?

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.


1 Answers

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

like image 127
Bob Snyder Avatar answered Oct 15 '22 02:10

Bob Snyder