【问题标题】:Firebase Swift equivalent of push()Firebase Swift 相当于 push()
【发布时间】:2017-08-08 14:02:13
【问题描述】:

在 Javascript 中,对 firebase ref 调用 push 会生成一个随机 ID。然后你可以填充下面的东西。

但是,我在 Swift 中找不到 push。我必须自己生成随机 ID 吗?

【问题讨论】:

    标签: ios swift firebase firebase-realtime-database


    【解决方案1】:

    我想你在找childByAutoId():

    childByAutoId 使用唯一键生成一个新的子位置并返回一个 FIRDatabaseReference 给它。当 Firebase 数据库位置的子项表示项目列表时,这很有用。

    childByAutoId: 生成的唯一键以客户端生成的时间戳为前缀,以便生成的列表按时间顺序排序。

    声明

    func childByAutoId() -> FIRDatabaseReference
    

    另见:https://firebase.google.com/docs/database/ios/read-and-write#update_specific_fields

    【讨论】:

    • 谢谢!我正在浏览文档以查找 push 一词,但它不存在
    猜你喜欢
    • 2018-09-10
    • 2018-11-28
    • 2019-09-10
    • 2016-12-11
    • 2011-05-31
    • 1970-01-01
    • 2020-09-11
    • 1970-01-01
    相关资源
    最近更新 更多