WEBVTT 0 00:00.240 --> 00:07.410 So previously we've seen how to create, read and update using MongoDB in the Mongo shell. And now 1 00:07.410 --> 00:12.000 it's time to look at how we would delete data from our collections. 2 00:12.030 --> 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 00:18.340 --> 00:24.650 And you can see that the two main methods we'll rely on is deleteOne and deleteMany. 4 00:24.660 --> 00:27.370 And this is an example of how you would use it. 5 00:27.450 --> 00:35.460 So you would say db.collection name.deleteMany or deleteOne and in the filter you would specify 6 00:35.730 --> 00:38.510 which records you want to delete. 7 00:38.520 --> 00:44.700 This is a good opportunity to translate what you see in the documentation to actual working code that 8 00:44.700 --> 00:46.750 does what you want it to. 9 00:46.830 --> 00:53.490 I want you to remove this second record that we added which is the pencil record by reading and using 10 00:53.490 --> 00:55.590 the documentation on MongoDB. 11 00:55.740 --> 00:58.160 Pause the video now and give that a try. 12 01:00.410 --> 01:01.120 OK. 13 01:01.190 --> 01:05.920 As we saw over here all we need to implement is db.collection 14 01:06.020 --> 01:15.520 .deleteOne. And we're going to say db.products.deleteOne and then we're going to provide 15 01:15.550 --> 01:21.850 the filter to find the particular record that we want to delete which in our case it would be easier 16 01:22.180 --> 01:23.850 to just specify the id 17 01:23.920 --> 01:26.950 and in this case that's going to be equal to 2. 18 01:27.220 --> 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 01:34.150 --> 01:35.040 deleted. 20 01:35.310 --> 01:42.070 And now if we use that find method again you can see we only have one record in our products collection.