2017-05-27 9 views
0

私はfirebaseの雲の機能を学習しています。firebaseのクラウド機能で{pushId}を取得するにはどうすればよいですか?

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はどのように取得できますか?私はdocsを見て何も見つかりませんでした。

pushIdがわからない人のために。この関数は、/ table内の要素の内部で行われたすべての変更をリッスンします。例えば:

  • /テーブル/ 1でpushIdはpushIdは/表2
  • ある/ N pushIDがN

答えて

5

ワイルドカードである/テーブル/ 2で1

  • あります参考パスではparamsオブジェクトに提供されます。

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