【发布时间】:2018-10-08 22:44:42
【问题描述】:
我已经编写了 firebase 云函数来触发更新记录。有时我没有得到相同的更新记录。我在下面添加我的代码。请检查附件图片。
exports.onNotificationUpdate = functions.database.ref('/Notification/{userId}/{notificationId}/userResponse').onUpdate(event => {
return admin.database().ref(`/Notification/${event.params.userId}/${event.params.notificationId}`).once('value').then(function (snapshot) {
var notification = snapshot.val();
if (!notification) {
console.error("Notification not found on notification update");
return;
};
我也可以从父级获取 Notification 对象,但我想知道问题的最佳方法和此代码的问题。
这是我在这里的第一篇文章,如果需要更多信息,请告诉我。 谢谢
【问题讨论】:
标签: javascript firebase firebase-realtime-database google-cloud-functions