Drop collection from database

Is it possible to drop a collection on server startup? I can’t find anything about dropping a collection. Not just empty a collection, but actually delete it.

In server-side code, for a collection named foo, I believe you should be able to do something like this:

new Mongo.Collection('foo').rawCollection().drop();

Hope that helps!

1 Like

Getting an error when trying that.

Error: There is already a collection named “mycollection”

I ended up using the values these collections where setup with. Seems to work ok.

Meteor.users.rawCollection().drop();
ServiceConfiguration.configurations.rawCollection().drop();

Thanks for the help @natedaly