https://firebase.google.com/docs/functions/beta-v1-diff
在文档中找不到event.params.pushId
和event.data.ref
event.params.pushId
和 event.data.ref
已更改为:
exports.dbWrite = functions.database.ref('/path/with/{pushId}').onWrite((change, context) => {
const wildcards=context.params.pushId;
const data=change.after.ref;
});
对于OnWrite和Onupdate事件,数据参数具有
before
和after
字段。这些都是DataSnapshot
,此处具有相同的方法:https://firebase.google.com/docs/reference/admin/node/admin.database.datasnapshot
ref
是DataSnapshot
的属性之一,因此您可以如上所述访问。
检查以下内容:
https://firebase.google.com/docs/functions/beta-v1-diff#realtime-database