Reputation: 21
I want to remove or delete one or more documents from a collection in MongoDB without using MongoDB Compass.
How can I remove or delete a document using Command Prompt ?
I have create a db 'University' and a collection 'names'. On the collection 'names' I have create 8 documents the 5 are full with data and the rest 3 are with data that I don't want them on my collection. How I can remove those 3 document?
Upvotes: 2
Views: 1273
Reputation: 516
Connect to mongo shell.
Run the following command
use db_name
db.getCollection(*collection_name*).deleteOne()
You can refer mongoDb doc as well.
Upvotes: 2