function triggerDocumentAnyChange()

in firestore/extend-with-functions/functions/index.js [64:79]


function triggerDocumentAnyChange() {
  // [START trigger_document_any_change]
  exports.modifyUser = functions.firestore
      .document('users/{userID}')
      .onWrite((change, context) => {
        // Get an object with the current document value.
        // If the document does not exist, it has been deleted.
        const document = change.after.exists ? change.after.data() : null;

        // Get an object with the previous document value (for update or delete)
        const oldDocument = change.before.data();

        // perform desired operations ...
      });
  // [END trigger_document_any_change]
}