如何在Firebase中设置属性?

时间:2017-05-15 06:19:21

标签: ios swift firebase

我需要设置" People" firebase中的属性。我不知道如何使用SWIFT设置字典属性。  我在下面添加了我尝试过的代码。

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

1 个答案:

答案 0 :(得分:0)

试试这个:

  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)

希望有所帮助