Search code examples
typescriptfirebasegoogle-cloud-firestoregoogle-cloud-functions

cloud function onUpdate inside document


it's possible to trigger onUpdate only on a document field?, I want to check if there's changes on the images field, that is an array, if yes, how I write the document path

exports.useWildcard = functions.firestore
.document('users/{userId}/????')
.onUpdate((change, context) => {
  
});

enter image description here


Solution

  • onUpdate triggers will fire when anything inside a matched document changes. It doesn't matter what changed.

    It's not possible to narrow a trigger down to a particular field. Triggers can only match an entire document. If you want to know if something changed in a field, you will need to write code to compare the "before" and "after" snapshots.