Guest User

Untitled

a guest
Nov 16th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. //del last 1000 documents
  2.  
  3. const arr = db.collection.find({}, { _id: 1 })
  4. .limit(1000)
  5. .sort({ "createdAt": -1 })
  6. .toArray()
  7. .map(function (doc) { return doc._id; });
  8.  
  9. db.collection.remove({_id: {$in: arr}})
Add Comment
Please, Sign In to add comment