删除节点 Firebase 下的所有项目

Removing All Items Under A Node Firebase

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

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?

只需调用myRef.removeValue()

解释在docs

The simplest way to delete data is to call removeValue on a reference to the location of that data.