Delete Documents
Learn and practice commands to delete single or multiple documents.
We'll cover the following
Delete a single document
Syntax for the deleteOne
command:
db.<collection-name>.deleteOne(
<filter query>,
<options>
);
The
filter query
andoptions
in thedeleteOne
command behave the same as they do in theupdateOne
command. The only difference is thatdeleteOne
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.