更新时间:2023-11-05 15:50:10
更改此内容:
exports.pushNotification = functions.database.ref('/messages').onWrite( event => {
const message = event.data.val();
const user = event.data.val();
});
到此:
exports.pushNotification = functions.database.ref('/messages').onWrite(( change,context) => {
const message = change.after.val();
});
请检查:
https://firebase.google.com/docs/functions/beta-v1 -diff#realtime-database
云功能已更改,现在 onWrite
有两个参数更改
和上下文
The cloud functions were changed and now onWrite
has two parameters change
and context
更改
在之前有两个属性,在
之后有,并且每个属性都是
DataSnapshot
使用此处列出的方法:
The change
has two properties before
and after
and each of these is a DataSnapshot
with the methods listed here:
https://firebase.google.com/docs/reference/admin/node/admin.database.DataSnapshot