From the course: MongoDB Java Developer Associate Cert Prep
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Deleting documents in MongoDB
From the course: MongoDB Java Developer Associate Cert Prep
Deleting documents in MongoDB
- Hi folks. In this video, you'll learn how to delete documents in MongoDB by using deleteOne and deleteMany. Let's jump right into it. Imagine that you're working with a database that contains information about various podcasts. There's a single document for each podcast that gets added to the collection, which is called podcasts, but there's a problem. At some point, a duplicate document for a podcast was inserted accidentally. We need to delete the duplicate. To achieve this, first we'll use find to determine which document to delete, and then we'll use the deleteOne method. Furthermore, your manager has asked you to remove all podcasts with a category of crime. First, we provide a filter document to the find method that contains the uploaded date of the duplicate document, which was provided to us by our manager. The date we were given is April 28th, 2020, and the shell will use the ISODate wrapper to specify the date running. This command returns the duplicate document. Now we'll…
Contents
-
-
-
-
-
-
-
Replacing a document in MongoDB3m 15s
-
(Locked)
Updating MongoDB documents by using updateOne()5m 56s
-
(Locked)
Updating MongoDB documents by using findAndModify()2m 35s
-
(Locked)
Updating MongoDB documents by using updateMany()3m 2s
-
(Locked)
Deleting documents in MongoDB2m 37s
-
(Locked)
MongoDB CRUD operations: Replace and delete documents review44s
-
-
-
-
-
-
-
-
-
-