Created
October 29, 2015 12:29
-
-
Save Stoffo/fd4a0a70be89e8d7ce15 to your computer and use it in GitHub Desktop.
Revisions
-
Stoffo created this gist
Oct 29, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ var date = new Date(); var daysToDeletion = 120; var deletionDate = new Date(date.setDate(date.getDate() - daysToDeletion)); printjson(deletionDate); var db = db.getSiblingDB('db') db.getMongo().setSlaveOk(); printjson(db.messages.find({insertDate : {$lt : deletionDate}}).count()); //delete old Messages: db.messages.remove({insertDate : {$lt : deletionDate}});