Reputation: 9748
I came by this problem on how to delete files older than a certain date and couldn't find a quick answer on the web, so here I'm posting the question and answering it, hopefully it'll save someone 15 minutes at some point.
Essentially I wanted to have the behavior of the following command (delete files older than five days) kind thing
find /path/to/files* -mtime +5 -exec rm {} \;
but in mongo.
Upvotes: 1
Views: 3898
Reputation: 31
Removing data from fs.files is not a good solution. You should always retreive the file_id from the fs.files and use the grid fs object to remove the same
Upvotes: 2
Reputation: 9748
db.fs.files.remove({"uploadDate": {$lt : ISODate("2013-11-10T20:32:13.743Z")}});
Upvotes: -1