Deleting Documents with the Remove,DeleteOne, and DeleteMany Methods in MongoDB

preview_player
Показать описание
Learn how to delete documents by using the remove, deleteOne, and deleteMany methods. The remove method can be used to remove 1 or more documents. The deleteOne method finds 1 document and then removes it. And the deleteMany method removes all documents that match the query.
If you want to follow along you can use the dummy data here:
If you don't know how to insert the dummy data you can follow the video here:
Рекомендации по теме
Комментарии
Автор

I was having a weird time trying to delete some items I had entered wrong for a lesson and this sorted me out in less than 3 minutes. Thank you

joshjacobson
Автор

I watched this entire series and I got a lot of value out of it. Thx for your time Pedro!

OK-edcm
Автор

Thanks a lot man, thanks a lot. I was frustrated when I was unable to delete the document from my database. The console always threw an exception 'guns is not defined'. guns was the name of my collection. I searched everywhere and my code was looking good, even my course instructor used the same syntax and it worked well on her system but on mine it didn't work. Then I added db.guns.deleteMany
and it worked.
Thanks Man.

rahulrajtripathi
Автор

You have a great teaching style! I'd love to bring more awareness to your channel by posting some of your tutorials on our channel (with links to your channel). If you are interested in discussing, send me an email at beau@[channelName].

freecodecamp
Автор

hey great work, but what is the difference between remove and deleteMany?

shahrozkhan
Автор

well how do we deleteOne if we don't know the object id?

nympho
Автор

Hello Sir Please help Me with an issue


This is about deletion of batch files that contain a specific term

I have 1000 documents in my cluster

What I want to do is

I want to delete all the files that have a specific word in their 'file_name'

Example

Under field - 'file_name'

1. Thor Ragnarok
2. Thor 2
3. Avengers

Now please help me with a command that

Deletes all the files that contain the word THOR


THANKS 😊

BEST CHANNEL AND TUTORIALS EVER

HithaishiDesai