0
的發佈消息的列表。 這就是我得到的。我需要從用戶結構中獲得uid。然後我需要檢查用戶結構的uid,就像posts/uid一樣。這就是我不知道該怎麼辦,因爲我不知道你怎麼能在一個職位,有ID,例如得到:「-Kvs50Et17ilfzdgdhcK」。它需要以某種方式來檢查所有已放置,比從用戶UID的檢查同樣是作爲崗位的UID的職位。請幫忙!得到我想要證明<strong>當前用戶</strong>張貼的帖子</strong>的<strong>列表當前用戶
var Gametext: String = ""
var Consoletext: String = ""
var dataBaseRef: DatabaseReference! {
return Database.database().reference()
}
var post: Post! {
didSet {
let postsRef = dataBaseRef.child("posts/\(Auth.auth().currentUser!.uid)")
let userQuery = postsRef.queryOrdered(byChild: "uid").queryEqual(toValue: Auth.auth().currentUser!.uid)
userQuery.observe(.childAdded, with: { (snapshot) in
print(snapshot.childSnapshot(forPath: "Game").value as? String)
print(snapshot.childSnapshot(forPath: "Console").value as? String)
}) { (error) in
print(error.localizedDescription)
}
}
}
這裏是我的崗位結構:
{
"posts" : {
"-Kvs50Et17ilfzdgdhcK" : {
"Console" : "Xbox One",
"ExtraInfo" : "Test",
"Game" : "test",
"Gamertag" : "[email protected]",
"photoURL" : "",
"postDate" : 1.5074008811834E9,
"postId" : "C835A03A-9BAF-423E-87F0-60139DA893EB",
"uid" : "7E4vEew5RbMsWmSMijZxT4TzxHh1",
"username" : "dani Kemper"
}
},
這裏是我的用戶結構:
"users" : {
"7E4vEew5RbMsWmSMijZxT4TzxHh1" : {
"Console" : "Xbox One",
"Gamertag" : "[email protected]",
"country" : "Antigua & Barbuda",
"email" : "[email protected]",
"photoURL" : "",
"uid" : "7E4vEew5RbMsWmSMijZxT4TzxHh1",
"username" : "dani Kemper"
}
}
}
有一個錯誤:無法在線上調用非函數類型'NSEnumerator'的值:print(snapshot.children(「Game」)。value as?String) – Danjhi
您可以幫忙嗎? – Danjhi
@Danjhi它在回答'snapshot.child(「遊戲」)'說,不'.children' – Callam