vsivsi/meteor-file-collection

How to delete the whole file collection

dpatte opened this issue · 4 comments

I notice that you dont support .remove({})

as per this in your documentation:
"For safety, undefined and empty selectors (undefined, null or {}) are all rejected."

So how would I remove everything? By doing a find({}) and deleting each one individually?
I believe some of my docs may have lock issues in the collection due to a crash, so I want to rebuild the collection from scratch.

Thx

For cases like this you should just manually remove the three underlying collections from MongoDB directly using e.g. the mongo CLI or another admin tool of your choice. gridFS is just two MongoDB collections [name].files and [name].chunks. FC also uses a [name].locks collection. If you blow these three collections away (or remove all documents from them) then you can start fresh.

You can also do this within Meteor code by simply opening each of these collections by name as an ordinary Meteor collection. Then you can do whatever you want to them. Just don't create them the first time this way, because each gridFS collection has special indexes that won't get added properly if you manually create the collections. That's why I recommend just dropping the whole collection if you want to start again.

above comment edited to remove a ton of email header info junk at the bottom of the post

This worked great for me thank you. Wish there was a way to do this from within Meteor though.