Firebase将数据存储到根目录中

时间:2016-12-04 07:24:52

标签: swift firebase

我试图将数据存储到root中,这意味着我不使用任何子路径,这是正确的方法,我想存储“var Value”。提前谢谢。

我的JSon

my Json

我的代码

paymentStatus == "submitted_for_settlement"{
                    let paidStatus = [
                        "status":"paid",
                        "isReceiverPaid": false as AnyObject,
                        "totalPaid":amount,
                        "senderFee":1.5,
                        "senderRating":"notSet",
                        "receiverRating":"notSet",
                        "DateFundsWillRelease":"11/2/2017"

                ] as NSDictionary


let frontEnd = ["posts/\(self.postId!)/paidPostStatus":paidStatus]

let backEnd = ["userSubmitted/postPaymentMade":paidStatus]

let values = [
              "frontEnd":frontEnd,
              "backEnd":backEnd
             ]

FIRDatabase.database().reference().updateChildValues(values, 
                                   withCompletionBlock: {_,_ in

})

1 个答案:

答案 0 :(得分:0)

如果您的问题确实存在:

  

我试图将数据存储到根

然后回答是

let parentNodeRef = rootRef.child("my_parent_node")
parentNodeRef.setValue("my value")

将导致

your_root
 my_parent_node: "my value"

如果你的确意味着没有子节点,那么这就是答案(请不要这样做,因为它会擦除节点中的所有内容)

rootRef.setValue("Don't do this")

,它为您提供没有子值的父级

your_root: "Don't do this"