Iñaki Arango
Iñaki Arango

Reputation: 89

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?

Upvotes: 0

Views: 2197

Answers (1)

cartant
cartant

Reputation: 58400

In the latest Firebase SDK, ref is a property and not a function:

var locationReference = locationSnapshot.ref;

Upvotes: 4

Related Questions