如何使用 firebase 云函数检索 {pushId}?
How can retrieve {pushId} with firebase cloud functions?
我正在学习 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?我查看了 docs,但找不到任何内容。
对于那些不知道 pushId 的人。这个函数监听 /table 中元素内部所做的每一个变化。例如:
- 在/table/1中pushId为1
- 在 /table/2 中 pushId 为 2
- 在/table/N中pushID是N
ref路径中的通配符在事件params对象中提供:
exports.gameLoopBeing = functions.database.ref('/tables/{pushId}/gamestarted')
.onWrite(event => {
//I want to retrieve the pushID
console.log(event.params.pushId);
});
exports.gameLoopBeing = functions.database.ref('/tables/{pushId}/gamestarted')
.onWrite((change, context) => {
//I want to retrieve the pushID
console.log(context.params.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?我查看了 docs,但找不到任何内容。
对于那些不知道 pushId 的人。这个函数监听 /table 中元素内部所做的每一个变化。例如:
- 在/table/1中pushId为1
- 在 /table/2 中 pushId 为 2
- 在/table/N中pushID是N
ref路径中的通配符在事件params对象中提供:
exports.gameLoopBeing = functions.database.ref('/tables/{pushId}/gamestarted')
.onWrite(event => {
//I want to retrieve the pushID
console.log(event.params.pushId);
});
exports.gameLoopBeing = functions.database.ref('/tables/{pushId}/gamestarted')
.onWrite((change, context) => {
//I want to retrieve the pushID
console.log(context.params.pushId);
});