0

我该如何做?我使用下面的代码,但它不工作。我仍然收到通知时更新我的​​数据库Firebase onWrite触发器 - 更新时禁用触发器

exports.sendNewPostNotif = functions.database.ref('/News/{ID}').onWrite(event => { 


    const announce_data = event.data.val(); 
    const announce_data_type = announce_data.categ_post; 
    const announce_data_title = announce_data.title_post; 
    const announce_data_uid = announce_data.uid; id 
    const announce_post_key = announce_data.postkey; 

    if(!event.data.val()) { 
     return console.log('No data'); 
    } 

    if(event.data.previous.exist()) { 

     return; 
    } 

每当我送一个新的内容,它会经过onWrite事件再发通知。 Mmy目前的问题是每当我编辑帖子时,它都会发送一个我不需要的通知。我尝试了上述内容,并且它在我更新新闻内容时没有收到通知,但我在创建新内容时没有收到通知。

+0

没有看到再现问题的最小**完整**代码(http://stackoverflow.com/help/mcve),这将很难提供帮助。我们在这里错过了很多背景。代码在哪里运行?什么是'事件'? –

+0

这是类似的这个https://stackoverflow.com/questions/44677506/determining-whether-data-is-added-or-deleted-to-firebase-realtime-database – Ron

+0

很抱歉,如果我让你困惑。 – Ron

回答