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

Geo*_*oub 3 firebase google-cloud-functions firebase-admin

我正在学习firebase云功能.我有一个看起来像这样的功能:

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

});
Run Code Online (Sandbox Code Playgroud)

event.data.pushID显然不起作用.如何检索pushID?我查看了文档但找不到任何内容.

对于那些不知道pushId的人.此函数侦听/ table内元素内所做的每个更改.例如:

  • 在/ table/1中,pushId为1
  • 在/ table/2中,pushId为2
  • 在/ table/N中,pushID是N.

Bob*_*der 8

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

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

});
Run Code Online (Sandbox Code Playgroud)