Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //del last 1000 documents
- const arr = db.collection.find({}, { _id: 1 })
- .limit(1000)
- .sort({ "createdAt": -1 })
- .toArray()
- .map(function (doc) { return doc._id; });
- db.collection.remove({_id: {$in: arr}})
Add Comment
Please, Sign In to add comment