![](/img/trans.png)
[英]What's the difference between Firebase AngularFireAuth and Auth?
[英]Firebase - What is the difference between ref and child?
Firebase中ref
和child
用的比較多。
例如 - firebase.database().ref('users/<user-id>')
將與firebase.database().ref('users').child('<user-id>')
完全相同,那么它們之間到底有什么區別,什么時候應該使用它們呢?
沒有任何區別,無論如何您都有DatabaseReference
實例。
Firebase引用表示數據庫中的特定位置,可用於讀取或寫入該數據庫位置的數據。
方法:
public DatabaseReference getReference (String path)
獲取提供的路徑的DatabaseReference。
方法:
public DatabaseReference child (String pathString)
獲取相對於此位置的參考。
你寫的兩種方式沒有區別。 唯一的問題是第一個是速記,“/”有點意思是“孩子”。 順便說一下,你提出的標題問題不是你的問題實際上是什么。 “Ref”和“child”是完全不同的東西,因為“ref”只是指示數據應該去哪里,“child”指定旅行數據的更准確位置。 我建議改變這一點。
簡單來說,ref 僅指向所述數據的 memory 位置,而 child 具有該位置。 換句話說,您可以說對某個位置的引用是由子項實現的。 但是,它類似於您擁有 Users/22222/image.jpg 的存儲路徑
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.