How can I modify the code below so that the Function only triggers when a child is added? Currently, the Function is triggered everytime there's a change in the specified reference...
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.myFunction = functions.database.ref('/messaging/{pushId}')
.onWrite(event => {
//child is added. Do something!
});
Use the onCreate() handler instead of
onWrite()
.