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.

Get hands-on with 1400+ tech skills courses.