简体   繁体   中英

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. 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM