问题描述
在Firebase中,经常使用ref
和child
.
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?
推荐答案
没有区别,无论如何,您都有一个 DatabaseReference
实例.
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有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!