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
.
Press + to interact
db.tasks.deleteOne({_id: ObjectId("60f7d855b307d94301b9cb90")});
This query ...
Access this course and 1400+ top-rated courses and projects.