以下是最新firebase云功能SDK上的非HTTP代码
exports.dbWrite = functions.database.ref('/pat/with/{id}').onWrite((data, context) => {
const authVar = context.auth;
const authType = context.authType;
const pathId = context.params.id;
const eventId = context.eventId;
const timestamp = context.timestamp;
const eventType = context.eventType;
const resource = context.resource;
});
答案 0 :(得分:2)
您应该可以访问以下字段:
exports.dbWrite = functions.database.ref('/path').onWrite((data, context) => {
const beforeData = data.before.val(); // data before the write
const afterData = data.after.val(); // data after the write
});
如文档中所述:https://firebase.google.com/docs/functions/beta-v1-diff#event_parameter_split_into_data_and_context(“事件数据现在是数据快照”)