【发布时间】:2018-04-16 06:09:38
【问题描述】:
如何检查特定节点是否发生了变化?
在
event.data.child("chatid").changed()
我找不到任何关于此的文档。我正在关注这个example:
change.after.changed('subscribedToMailingList')
并在控制台中收到错误:
change.after.changed 不是函数
exports.ObserveProposals = functions.database.ref("/proposals/{jobid}/{talentid}").onWrite((change, context) => {
const jID = context.params.jobid;
const tID = context.params.talentid;
let jR = admin.database().ref(`/jobs/${jID}`);
const promises = [];
if (change.after.exists() && change.after.changed('chatid') && change.after.child("chatid").val()) return null;
...
if语句出现错误
【问题讨论】:
-
请编辑您的问题以显示未按您期望的方式工作的代码(不仅仅是一行)。
-
你试过比较“之前”和“之后”吗? change.after.val().subscribedToMailingList != change.before.val().subscribedToMailingList
-
我已经更新了我的问题
-
@AarónBC。我更喜欢使用改变的方法
-
嗯,看v1的迁移指南,对象类型好像从DeltaSnapshot变成了DataSnapshot。 DeltaSnapshot 是具有 changed() 方法的类型。见:firebase.google.com/docs/functions/…
标签: firebase firebase-realtime-database google-cloud-functions