lila/bin/mongodb/clean-unplayed.js

25 lines
494 B
JavaScript
Raw Normal View History

var d = new Date();
2021-02-06 06:26:05 -07:00
d.setDate(d.getDate() - 1);
2021-02-06 06:26:05 -07:00
var ids = db.game4
.find({ t: { $lt: 2 }, ca: { $lt: d } }, { _id: 1 })
.limit(1000)
.toArray()
.map(function (g) {
return g._id;
});
var nb = ids.length;
if (nb > 0) {
2021-02-06 06:26:05 -07:00
print('First ID: ' + ids[0]);
}
2021-02-06 06:26:05 -07:00
print('Remove ' + nb + ' games');
db.game4.remove({ _id: { $in: ids } });
2021-02-06 06:26:05 -07:00
print('Remove ' + nb + ' pgns');
db.pgn.remove({ _id: { $in: ids } });
2021-02-06 06:26:05 -07:00
print('Remove ' + nb + ' bookmarks');
db.bookmark.remove({ g: { $in: ids } });