June 2018
Beginner to intermediate
394 pages
9h 2m
English
Functions for Firestore allow developers to use the onUpdate function with a wildcard to trigger a function when a document is updated or has some change values. The following example illustrates the onUpdate function and its event callbacks:
exports.updateUser = functions.firestore .document('users/{userId}') .onUpdate(event => { // e.g. {'name': 'Srinivasa', 'age': 61} //indicates the new value var newValue = event.data.data(); // indicates the old value var previousValue = event.data.previous.data(); var name = newValue.name; // perform desired operations ... });
This code is very straightforward; we can perform the desired task based on this data.
Read now
Unlock full access