如何访问Firebase云功能中的节点键的值

时间:2017-11-17 10:29:17

标签: javascript node.js firebase firebase-realtime-database google-cloud-functions

我目前正在使用Firebase云功能,我需要在继续之前检查用户ID是否与当前登录的用户相同。在访问下面的帖子之前,我如何能够检查节点中的userID。

Database example

我一直在尝试使用数据库触发器,因为我想检查对数据库的写入。

到目前为止,我已经写了这个功能,但是

exports.sendPushNotification = functions.database.ref('/competitions').onWrite(event => {
const collectionRef = event.data.ref.parent;
snapshot.forEach(function () {
    const countRef = collectionRef.parent.child('posts');

});

});

我只是不知道如何将用户ID作为变量

进行访问

0 个答案:

没有答案