Delete documents that are older than a certain time period

var older=Date.parse("2013-03-01"), all=collection.find();
all.forEach(function(doc) { var ts = doc._id.getTimestamp();
    if (ts < older) { collection.remove(doc); } });

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327011690&siteId=291194637