It's a simple question, I have seen all these methods addressed in the title in the documentation but all the examples are using onWrite() for triggering database events which then one would have to check to make sure it's not for removing or updating with
exports.makeUppercase = functions.database.ref('/messages/{pushId}/original')
.onWrite(event => {
...
// Only edit data when it is first created.
if (event.data.previous.exists()) {
return;
}
// Exit when the data is deleted.
if (!event.data.exists()) {
return;
}
...
});
The only examples with onCreate() for instance, are related to auth events. Is there a reason or am I just being paranoid? Why not just use onCreate() and not bother the check?