Matt Butler Matt Butler - 11 months ago 96
Swift Question

Update existing data in Firebase (Swift)

Firebase Data Structure:

- 90384m590v834dfgok34
•userName: "Matt"
•values: ["test1", "test2"]

I am wanting to update the values inside of these firebase entries without replacing the whole thing. I know the update() function is what I need to do, but from the example I tried it is not working.

Also, how would I append a new item to the values array through the update() function?

Answer Source

Create a reference for the user whose values you'd like to update and use updateChildValues.

let ref = FIRDatabase.database().reference().child("users/90384m590v834dfgok34")

    "values": [