如何使用Firebase云功能检索{pushId}?

牧岛寿吾

我正在学习Firebase云功能。我有一个看起来像这样的函数:

exports.gameLoopBeing = functions.database.ref('/tables/{pushId}/gamestarted')
    .onWrite(event => {
    //I want to retrieve the pushID        
    console.log(event.data.pushID);

});

event.data.pushID显然不起作用。如何获取pushID?我看了看文档,找不到任何东西。

对于那些不知道pushId是的人。此函数侦听/ table内元素内部所做的所有更改。例如:

  • 在/ table / 1中,pushId为1
  • 在/ table / 2中,pushId为2
  • 在/ table / N中,pushID为N
鲍勃·斯奈德

ref路径中的通配符在event params对象中提供:

exports.gameLoopBeing = functions.database.ref('/tables/{pushId}/gamestarted')
    .onWrite(event => {
    //I want to retrieve the pushID        
    console.log(event.params.pushId);

});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章