I have the following functions that listen for the onWrite event for a database trigger as follows:
exports.sendNotifications = functions.database.ref('/events/{eventId}/registered')
.onWrite(event => {
...
});
The above function is called regardless of whether node is removed or added. How to check if the onWrite event is a “delete” event for this particular node or “add” event, so that this function is called only when it is an “add”.
source
share