...

/

Delete Documents

Delete Documents

Learn and practice commands to delete single or multiple documents.

Delete a single document

Syntax for the deleteOne command:

db.<collection-name>.deleteOne(
    <filter query>,
    <options>
);

The filter query and options in the deleteOne command behave the same as they do in the updateOne command. The only difference is that deleteOne deletes only one document.

Below is an example of a query to delete a document by _id.

Press + to interact
db.tasks.deleteOne({
_id: ObjectId("60f7d855b307d94301b9cb90")
});

This query ...

Access this course and 1400+ top-rated courses and projects.