【问题标题】:How can I edit multiple data in Firebase database?如何在 Firebase 数据库中编辑多个数据?
【发布时间】:2017-01-11 15:19:15
【问题描述】:

我有一个包含用户信息的孩子。 我需要同时更改“FirstName”和“LastName”。 如何设置子级和值?。

【问题讨论】:

    标签: ios swift firebase swift3 firebase-realtime-database


    【解决方案1】:

    你可以使用updateChildValues:

    var updates : [AnyHashable: Any] = ["your/path/firstName": firstName,
                                        "your/path/lastName": lastName]
    ref.updateChildValues(updates)
    

    【讨论】:

    • 是的!我也刚发现这个。不过谢谢你的回答。
    【解决方案2】:

    我找到了解决方案!! 在“child”键中使用“updateChildValues”而不是“setValue”。

    【讨论】:

      【解决方案3】:
      ref.child("users").child(uid).child("firstName").setValue(firstName)
      ref.child("users").child(uid).child("lastName").setValue(lastName)
      

      如有必要,更改路径以适合存储数据的位置

      【讨论】:

      • 我刚刚找到了解决方案。它应该使用“updateChildValues”。
      猜你喜欢
      • 2022-11-12
      • 2018-01-20
      • 1970-01-01
      • 2018-12-23
      • 1970-01-01
      • 2017-09-29
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多