我是 Firebase 概念的新手,但我想做的是将一个新的 Firebase 元素添加到我的“组”类别中,其中树结构如下:
Groups:
---- GroupID (provided by firebase)
---- GroupPW (provided by user that create new group)
---- GroupName (provided by user that create new group)
---- etc....
我在 ViewController 中的 CreateGroup IBAction 按钮下有以下内容:
let group = Group(groupName: self.name.text!, groupPW: self.password.text!)
let ref = FIRDatabase.database().reference()
let key = ref.child("Groups").childByAutoId().key
taskFirebasePath.setValue(group.toDictionary())
我不确定现在该做什么?
最佳答案
我不确定 taskFirebasePath
是什么。但是如果你想插入数据到group
,我认为应该把它改成。
let group = Group(groupName: self.name.text!, groupPW: self.password.text!)
let ref = FIRDatabase.database().reference()
let childRef= ref.child("Groups").childByAutoId().child(self.password.text!)
childRef.setValue(group.toDictionary())
关于ios - Firebase 插入具有 2 个关键属性的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43173370/