[英]Swift 3.0 How to add a child on a parent in firebase
我认为您的问题是您要添加另一个子节点吗?
假设用户已通过身份验证,并且其uid为uid_0
class ViewController: UIViewController {
var ref: DatabaseReference!
override func viewDidLoad() {
super.viewDidLoad()
self.ref = Database.database().reference()
let uid = Auth.auth().currentUser?.uid
let thisUsersGamesRef = self.ref.child("users").child(uid!).child("Games")
let gameRef0 = thisUsersGamesRef.childByAutoId().child("game_url")
gameRef0.setValue("http://www...")
let gameRef1 = thisUsersGamesRef.childByAutoId().child("game_url")
gameRef1.setValue("http://www..")
}
会给
users
uid_0
email: ....
Games:
-Yuhu98js9d
game_url: "http://www..."
-H89j90k0s0
game_url: "http://www..."
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.