senty senty - 4 months ago 28
Swift Question

Removing All Items Under A Node Firebase

I am trying to remove all the children under a node. Is there a way to delete all the items under a node? The structure is like:

- mainId
- timestampedId
- keys:values

What I want to do is, by using
, delete all the items under it. Actually there's only one
at a time as this is for lastMessages. That's why I thought I should delete all items under
just before writing my new value. Is there a way to achieve that; or is there any better ways than I thought?

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

// how to delete all items under myRef?


Simply call myRef.removeValue()

Explained in the docs

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