Firebase Overwrite Records

I am new to Firebase and don't know how best to explain this, but I will try.

I am trying to create an application for each user. Then each user record has several subscriptions (from 0 to n), where each subrecord is a simple string. Basically, there is a user identifier (master record), and their tasks are subheadings.

Now my problem is that whenever I click on the data (subtitles) on the main records, all the previous subtitles are deleted, but only the most recent. I looked through the documentation and google like crazy but nothing works.

I tried this:

@IBAction func testWrite(sender: AnyObject) {
    let def = NSUserDefaults.standardUserDefaults()
    let uid = def.valueForKey("uid")
    let root = Firebase(url: getFirebaseURL())

    let text = self.tempText.text!
    let dataRef = root.childByAppendingPath(uid as! String)
    let data = ["test": String(text)]
    dataRef.setValue(data)
}

Which adds to the entry entry user ID, with the key "test" and the value "text"

So, I kill the application and change it to:

@IBAction func testWrite(sender: AnyObject) {
    let def = NSUserDefaults.standardUserDefaults()
    let uid = def.valueForKey("uid")
    let root = Firebase(url: getFirebaseURL())

    let text = self.tempText.text!
    let dataRef = root.childByAppendingPath(uid as! String)
    let data = ["CHANGED": String(text)]
    dataRef.setValue(data)
}

, , , , - .

, , , ( ?) , .

, : P !

+4
2

, (Users/UserID ##) , node Changed:<somestring>

, , (Users/UserID ##/TaskID ##)

, , , :
Users/UserID = Key:Value

:
Users/UserID/Key = Value

: Users/UserID/Key , .


, , :

let dataRef = root.childByAppendingPath(uid as! String + "/Task001")
dataref.setValue(String(text))

, , , - Firebase . , , , childByAutoId, , , .

: .

+4

@MtlDev updateChildValues():

let data = ["CHANGED": String(text)]
dataRef.updateChildValues(data)

setValue() , updateChildValues() .

. Firebase .

+4

All Articles