简体   繁体   中英

How to set Attributes in Firebase?

I need to set the "People" attribute in firebase. I don't know how to set dictionary attribute using SWIFT. I have added my code below which I have tried .

let key = snapshot.key

        let upload = ["id":key,
                  "status":status,] as [String : Any]

        databaseRef.child("location").child(key).setValue(upload)

This image is firebase data

Try this:

  let key = snapshot.key

  let updates: [String: Any] = [
     "/id": key,
     "/people/name1": <yourValue>,
     "/people/name2": <yourValue>,
     "/status": status
  ]

  databaseRef.child("location").child(key).updateChildValues(updates)

Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM