【问题标题】:Removing All Items Under A Node Firebase删除节点 Firebase 下的所有项目
【发布时间】:2016-06-11 05:36:50
【问题描述】:

我正在尝试删除节点下的所有子节点。有没有办法删除节点下的所有项目?结构如下:

lastMessages
  - mainId
    - timestampedId
      - keys:values

我想要做的是,通过使用mainId,删除它下面的所有项目。实际上一次只有一个timestampedId,因为这是用于lastMessages。这就是为什么我认为我应该在写我的新值之前删除mainId 下的所有项目。有没有办法做到这一点?或者有没有比我想象的更好的方法?

let ref = Firebase(url: path)
let myRef = ref.childByAppendingPath(mainId)   

// how to delete all items under myRef?

【问题讨论】:

    标签: ios swift firebase firebase-realtime-database


    【解决方案1】:

    只需拨打myRef.removeValue()

    解释在docs

    删除数据的最简单方法是在对该数据位置的引用上调用 removeValue。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多