Ziya ERKOC
Ziya ERKOC

Reputation: 839

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.

Upvotes: 13

Views: 3344

Answers (1)

Bob Snyder
Bob Snyder

Reputation: 38319

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

Upvotes: 17

Related Questions