Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get firebase.database.Reference full path

consider

var adaRef = firebase.database().ref("users/ada");

How can I get the full path of ref ? that is "users/ada" ?

like image 393
kofifus Avatar asked Jun 17 '16 03:06

kofifus


1 Answers

That's surprisingly simple:

adaRef.toString()

Will print the full URL: https://<your-app>firebaseio.com/users/ada

So to just get the path, you substring it out of there. Two ways of doing that are:

adaRef.toString().substring(firebase.database().ref().toString().length-1)

or:

adaRef.toString().substring(adaRef.root.toString().length-1)

both will print /users/ada

like image 191
Frank van Puffelen Avatar answered Sep 28 '22 05:09

Frank van Puffelen