Reputation: 89
How to remove a document in MongoDB where I want to remove id 1 to 1000, In the collection, I have 10 million documents.
db.posts.remove(
{ "id": 1 to 1000}
)
Upvotes: 0
Views: 158
Reputation: 326
You can execute the command below on shell
db.posts.deleteMany({$and: [{"id": { $gte: 1} }, {"id": { $lte: 1000} }] )
For reference, you can also visit MongoDocs.
Upvotes: 0
Reputation: 787
You can use this query
db.posts.remove({"$and" : [{"id" :{"$gte" :1}},{"id" :{"$lte" :1000}}]})
Upvotes: 0