我有一个在“用户”下更新“位置”时会触发的功能。我希望能够遍历所有“用户”并能够比较他们的“位置”。
现在当我在console.log event.data.val()
时,我只获得了“位置”数据。
我如何升级并看到其他'用户'
exports.getNearest = functions.database.ref('/users/{pushId}/location').onWrite(event =>{
console.log(event.data.val());
return;
}
);
我的数据库结构如下:
答案 0 :(得分:0)
event.data.ref is a Reference where your function triggered. This means event.data.ref.parent is a reference to the parent node of that location. You can reach the root of your database using event.data.ref.root. If you need full read and write access regardless of the user who invoked the function, you may also want to use event.adminRef instead of ref.