ios - Firebase 插入具有 2 个关键属性的数据

标签 ios swift firebase firebase-realtime-database

我是 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/

相关文章:

基于运算符的 Swift 泛型约束

java - 在 Firebase Admin SDK 之上创建 REST API Controller

javascript - Firebase Auth - 最近登录多长时间

ios - 如何在同一个应用中支持IOS6和IOS7的应用图标和启动图像?

ios - 具有通配符配置文件的临时分发

ios - 如何用倾斜的渐变填充 CAShapeLayer

ios - signInWithPhoneNumber() 在 react native 中不起作用

objective-c - 从应用程序打开 prezi

ios - 如何快速打开电影画廊

ios - 如何在 Swift 中使用 ABPeoplePickerNavigationController 选择多个联系人