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?
mongo --port 27017to connect to shell 2.use University3.show collectionswill show you collections on the db, if you see anamescollection.?namescollection, you know ids of those documents right. Do as one of the answers.db.names.deleteOne({_id: ObjectId('idofdoctodelete')}). That you run 3 times for those 3 docs.