Firebase-ref和child有什么区别? [英] Firebase - What is the difference between ref and child?

查看:105
本文介绍了Firebase-ref和child有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Firebase中,经常使用refchild.

In Firebase, ref and child are used a lot.

例如-firebase.database().ref('users/<user-id>')将与firebase.database().ref('users').child('<user-id>')完全相同,那么它们之间到底有什么区别?何时应使用它们中的任何一个?

For example - firebase.database().ref('users/<user-id>') will work exactly same as firebase.database().ref('users').child('<user-id>'), so what exactly is the difference between them and when should either of them be used?

推荐答案

没有区别,无论如何,您都有一个

There is no difference, in any case you have a DatabaseReference instance.

Firebase参考代表数据库中的特定位置,可用于将数据读取或写入该数据库位置.

A Firebase reference represents a particular location in your Database and can be used for reading or writing data to that Database location.

方法:

public DatabaseReference getReference (String path)

获取所提供路径的DatabaseReference.

Gets a DatabaseReference for the provided path.

方法:

public DatabaseReference child (String pathString)

获取相对于此位置的参考.

Get a reference to location relative to this one.

这篇关于Firebase-ref和child有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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