问题
How to trigger the firebase cloud function onUpdate
each time any of the child "order_status" is == "accepted"
(included the old Childs on trigger)
my code won't work
Have a look please :
Code:
exports.checkOrderStatus = functions.database.ref("/RestaurantOrders").onUpdate(async (change, context) => {
var orderStatus = change.after.val().order_status;
if (orderStatus == "accepted") {
code...
} else {
return
}
}
回答1:
exports.checkOrderStatus = functions.database.ref("/RestaurantOrders/{pushId}").onUpdate((change, context) => {
var orderStatus = change.after.val().order_status;
if (orderStatus == "accepted") {
code...
} else {
return
}
});
来源:https://stackoverflow.com/questions/65385589/firebase-cloud-function-onupdate-child-of-list-nodejs