Firebase cloud function onUpdate child of list (NodeJs)

巧了我就是萌 提交于 2021-01-29 20:29:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!