https://mongoosejs.com/docs/5.x/docs/api.html#model_Model.deleteMany
mongoose.connection.db.collection('sessions', function (err, collection) {
collection.deleteMany({ session: { $not: /.*passport.*/i }}, function(err, result){
console.log(err);
console.log(result);
});
});
How do I limit this to only 100 documents? I tried
collection.deleteMany({ session: { $not: /.*passport.*/i }}, { limit: 100}, function(err, result){
console.log(err);
console.log(result);
});
because it looked like from the documents that may worked, but it didn't it deleted every document. How do I limit to only 100 documents?