I want to have an updatedAt
field in my pizza
document that should be updated every time there's an update happening in this particular document. I think the best place to handle this is in an onUpdate
trigger:
exports.onUpdatePizza = functions.firestore
.document('pizzas/{pizzaId}')
.onUpdate(async (change, context) => {
return change.after.ref.update({ updatedAt: new Date() });
});
However, the above code will fall into an infinite loop. How can I implement this without the undesired side effect?