Clear a collection in Meteor

Published on May 25, 2016

While working on my gaming guild website, I needed to dump my Categories collection and just reseed it. We are talking emptying gas cans and lighting a match style.

To remove a single item, we can pass in the id of the document to remove.

Categories.remove("uxccA7un7mjFmyqDn");

We can also remove all the items that match a query.

Categories.remove({ name: 'general' });

And to remove all the items? Well we just pass in an empty query so it matches everything!

Categories.remove({});

References