How can retrieve {pushId} with firebase cloud functions?

Viewed 1281

I am learning firebase cloud functions. I have a function that looks like that:

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

});

event.data.pushID clearly doesn't work. How can retrieve the pushID? I looked at the docs and couldn't find anything.

For those who don't know that pushId is. This function listens to every change done inside elements inside /table. For example:

  • in /table/1 the pushId is 1
  • in /table/2 the pushId is 2
  • in /table/N the pushID is N
2 Answers
exports.gameLoopBeing = functions.database.ref('/tables/{pushId}/gamestarted')
     .onWrite((change, context) => {
     //I want to retrieve the pushID        
      console.log(context.params.pushId);
    });
Related