What is the command to remove one specific document from the database?

QuestionsQuestions8 SkillsProYour First MongoDB LabNov, 26 2025
083

To remove one specific document from the database, you can use the deleteOne method. Here’s an example command:

db.collectionName.deleteOne({ fieldName: "value" })

Replace collectionName with the name of your collection, fieldName with the field you want to match, and "value" with the specific value of that field for the document you want to delete.

For example, to delete a book with the title "MongoDB Basics", you would use:

db.books.deleteOne({ title: "MongoDB Basics" })

0 Comments

no data
Be the first to share your comment!