1. Delete one
deleteOne removes the first document matching the filter.
db.users.deleteOne({ name: "Ada" })Typorithm · medium
Step 1 of 8 · intro card
CRUD
deleteOne removes the first match; deleteMany removes all matches. Always pass a scoped filter — an empty filter on deleteMany wipes the entire collection.
deleteOne removes a single matching document; deleteMany removes every document that matches the filter.
The filter is what keeps a delete safe: { name: "Ada" } targets one person, while { active: false } targets a whole class.
Beware the empty filter: db.users.deleteMany({}) deletes every document in the collection — there is no undo.
deleteOne removes the first match.
deleteMany removes all matches.
An empty filter on deleteMany clears the collection.
db.users.deleteOne({ name: "Ada" })
db.users.deleteMany({ active: false })Connect each part of the code to the concept before you type.
deleteOne removes the first document matching the filter.
db.users.deleteOne({ name: "Ada" })A precise filter limits the delete to exactly the intended document.
{ name: "Ada" }deleteMany removes every document matching the filter.
db.users.deleteMany({ active: false })This filter selects all inactive users for removal.
{ active: false }Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.