如何获取firebase.database.Reference的完整路径 [英] how to get firebase.database.Reference full path

查看:100
本文介绍了如何获取firebase.database.Reference的完整路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑

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

如何获取ref的完整路径?那是用户/用户"?

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

推荐答案

这非常简单:

adaRef.toString()

将打印完整的URL:https://<your-app>firebaseio.com/users/ada

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)

或:

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

都将打印/users/ada

这篇关于如何获取firebase.database.Reference的完整路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆