Delete Documents
Learn and practice commands to delete single or multiple documents.
We'll cover the following...
We'll cover the following...
Delete a single document
Syntax for the deleteOne command:
db.<collection-name>.deleteOne(
<filter query>,
<options>
);
The
filter queryandoptionsin thedeleteOnecommand behave the same as they do in theupdateOnecommand. The only difference is thatdeleteOnedeletes only one document.
Below is an example of a query to delete a document by _id.
This query ...