Skip to content

Instantly share code, notes, and snippets.

View gniting's full-sized avatar
🐢

Nitin Gupta gniting

🐢
View GitHub Profile
@gniting
gniting / mongo_prune_js.js
Created August 12, 2025 08:03 — forked from arevindh/mongo_prune_js.js
mongo_prune_js.js
// keep N-day worth of data
var days=7;
// change to false to have the script to really exclude old records
// from the database. While true, no change at all will be made to the DB
var dryrun=true;
var now = new Date().getTime(),
time_criteria = now ;
time_criteria_in_seconds = time_criteria / 1000;