0 1 00:00:00,240 --> 00:00:07,410 So previously we've seen how to create, read and update using MongoDB in the Mongo shell. And now 1 2 00:00:07,410 --> 00:00:12,000 it's time to look at how we would delete data from our collections. 2 3 00:00:12,030 --> 00:00:18,170 And again if I scroll down in this CRUD documentation we've got a section that tells us how to do this. 3 4 00:00:18,340 --> 00:00:24,650 And you can see that the two main methods we'll rely on is deleteOne and deleteMany. 4 5 00:00:24,660 --> 00:00:27,370 And this is an example of how you would use it. 5 6 00:00:27,450 --> 00:00:35,460 So you would say db.collection name.deleteMany or deleteOne and in the filter you would specify 6 7 00:00:35,730 --> 00:00:38,510 which records you want to delete. 7 8 00:00:38,520 --> 00:00:44,700 This is a good opportunity to translate what you see in the documentation to actual working code that 8 9 00:00:44,700 --> 00:00:46,750 does what you want it to. 9 10 00:00:46,830 --> 00:00:53,490 I want you to remove this second record that we added which is the pencil record by reading and using 10 11 00:00:53,490 --> 00:00:55,590 the documentation on MongoDB. 11 12 00:00:55,740 --> 00:00:58,160 Pause the video now and give that a try. 12 13 00:01:00,410 --> 00:01:01,120 OK. 13 14 00:01:01,190 --> 00:01:05,920 As we saw over here all we need to implement is db.collection 14 15 00:01:06,020 --> 00:01:15,520 .deleteOne. And we're going to say db.products.deleteOne and then we're going to provide 15 16 00:01:15,550 --> 00:01:21,850 the filter to find the particular record that we want to delete which in our case it would be easier 16 17 00:01:22,180 --> 00:01:23,850 to just specify the id 17 18 00:01:23,920 --> 00:01:26,950 and in this case that's going to be equal to 2. 18 19 00:01:27,220 --> 00:01:34,150 So now if I hit enter then you can see that my request has been acknowledged and one record has been 19 20 00:01:34,150 --> 00:01:35,040 deleted. 20 21 00:01:35,310 --> 00:01:42,070 And now if we use that find method again you can see we only have one record in our products collection.