[英]Node.js: How can I get the reference for a Firebase Database Data Snapshot
I have a folder for each user. 我为每个用户都有一个文件夹。 I have a DataSnapshot name "snapshot" that selects an item of the user that has been changed.
我有一个DataSnapshot名称“快照”,用于选择已更改的用户项目。 Using the following code, i get the snapshot for the item I want in the same user:
使用以下代码,我可以在同一用户中获取所需项目的快照:
var locationSnapshot = snapshot.child("location");
This works. 这可行。 My question is how can I get the reference to this exact item in the database so that I can write it?
我的问题是如何获得对数据库中此确切项目的引用,以便可以编写它? Supposedly there is a function:
大概有一个功能:
ref
non-null firebase.database.Reference
The Reference for the location that generated this DataSnapshot.
But when I use it, it doesn't work: 但是当我使用它时,它不起作用:
var locationReference = locationSnapshot.ref();
Question : How do I use it or how do I get the reference? 问题 :如何使用它或如何获得参考?
在最新的Firebase SDK中, ref
是属性而不是函数:
var locationReference = locationSnapshot.ref;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.