我对Firebase概念不熟悉,但我要做的是在我的" Groups"中添加一个新的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())
我现在不确定该怎么做?
答案 0 :(得分:1)
我不确定taskFirebasePath
是什么。但是,如果您想将数据插入group
,我认为应该将其更改为。{/ p>
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())