how to get firebase.database.Reference full path

后端 未结 3 2068
感动是毒
感动是毒 2021-01-17 22:54

consider

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

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

3条回答
  •  佛祖请我去吃肉
    2021-01-17 23:17

    Following on Frank's answer I extended firebase as follows:

    firebase.database.Reference.prototype.fullkey = function() {
        return this.toString().substring(this.root.toString().length-1);
    }
    

    then you can do adaRef.fullkey() // returns /users/ada

    (I would like to call this 'path' but that seems to be reserved by FB)

提交回复
热议问题