在firebase上使用云函数时,使用onUpdate触发器,我如何检索已更新的记录(换句话说,触发函数的记录)?我正在使用 JavaScript 与 Firebase 数据库交互。
最佳答案
第一个参数通过了你的 onUpdate处理函数是 Change目的。这个对象有两个属性,before
和 after
, 两个 DataSnapshot对象。这些 DataSnapshot 对象描述了触发函数的更改前后的数据库内容。
exports.foo = functions.database.ref('/location-of-interest')
.onUpdate((change) => {
const before = change.before // DataSnapshot before the change
const after = change.after // DataSnapshot after the change
})
关于javascript - 在 Firebase 中使用 onUpdate 函数时,如何检索已更新的记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50938753/