繁体   English   中英

Firebase,显示带有下一个路径的帖子“ self.dataBaseRef.child(“帖子”).child(uid).childByAutoId()”

[英]Firebase ,Display post with The next path “self.dataBaseRef.child(”Posts“).child(uid).childByAutoId()”

我必须显示带有firebase的帖子,该帖子在路径上:

self.dataBaseRef.child("Posts").child(uid).childByAutoId()

哪里

"uid" = FIRAuth.auth()!.currentUser!.uid

dataBaseRef = FIRDatabaseReference! {
    return FIRDatabase.database().reference()
}

Firebase上的帖子发布成功,但是我无法走这条路,因为我无法声明uid因为它是针对每个用户的。 怎么样?

尝试这样:

let dataBaseRef = FIRDatabase.database().reference(withPath: "Posts")

dataBaseRef.observe(.value, with: { snapshot in
        for item in snapshot.children {
            let childSnap = item as! FIRDataSnapshot // do something you wants to
            // childSnap contains item in Posts. So in cycle you will catch
            // every post child node. From here you can get uid's 
            // and make a new observer
        }
})

希望能帮助到你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM