Firebase云功能onUpdate子列表(NodeJs) [英] Firebase cloud function onUpdate child of list (NodeJs)

查看:42
本文介绍了Firebase云功能onUpdate子列表(NodeJs)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在onUpdate上触发Firebase云功能

How to trigger the firebase cloud function onUpdate

每次孩子中的任何一个"order_status"是 ==已接受"

each time any of the child "order_status" is == "accepted"

(包括触发时的旧儿童)

(included the old Childs on trigger)

我的代码无法正常工作

请看一下:

代码:

  exports.checkOrderStatus = functions.database.ref("/RestaurantOrders").onUpdate(async (change, context) => {
        
            var orderStatus = change.after.val().order_status;
        
            if (orderStatus == "accepted") {
         code...
        
        } else {

        return 
    
    }

    }

推荐答案

  exports.checkOrderStatus = functions.database.ref("/RestaurantOrders/{pushId}").onUpdate((change, context) => {
        
            var orderStatus = change.after.val().order_status;
        
            if (orderStatus == "accepted") {
         code...
        
        } else {

        return 
    
    }

});

这篇关于Firebase云功能onUpdate子列表(NodeJs)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆