下面是我的數據結構:如何在swift中進行順序firebase查詢?
{
"posts": {
"xyz1": {
"author": "Jan",
"uid": "abc123",
},
"xyz2": {
"author": "Jenny",
"uid": "abc456",
},
}
"users": {
"abc123": {
"email": "[email protected]",
"profilePicURL": "https://firebasestorage.googleapis.com/v0/b/",
},
"abc456": {
"email": "[email protected]",
"profilePicURL": "https://firebasestorage.googleapis.com/v0/c/",
},
}
}
我想顯示「上崗」的實現代碼如下條目列表。
let postRef = ref.child("posts")
postRef.observe(.childAdded, with: { (snapshot) in
let authorText = snapshot.value!.object(forKey: "author") as! String
let userIDText = snapshot.value!.object(forKey: "uid") as! String
}) { (error) in
print(error.localizedDescription)
}
我如何使用「UID」從上面的查詢檢索,使連續的查詢檢索「profilePicURL」用在「用戶」的「UID」值。最終目標是在tableview中顯示除帖子之外存儲的profilePic。
謝謝你提供的任何幫助。
嗨大衛,謝謝你的及時回覆。但是,您的回覆並不能真正解決我的問題。 –
我用另一種方法使用緩存來加載圖像。 –