Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
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
2
00:00:07,410 --> 00:00:12,000
it's time to look at how we would delete data from our collections.
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.
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.
5
00:00:24,660 --> 00:00:27,370
And this is an example of how you would use it.
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
7
00:00:35,730 --> 00:00:38,510
which records you want to delete.
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
9
00:00:44,700 --> 00:00:46,750
does what you want it to.
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
11
00:00:53,490 --> 00:00:55,590
the documentation on MongoDB.
12
00:00:55,740 --> 00:00:58,160
Pause the video now and give that a try.
13
00:01:00,410 --> 00:01:01,120
OK.
14
00:01:01,190 --> 00:01:05,920
As we saw over here all we need to implement is db.collection
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
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
17
00:01:22,180 --> 00:01:23,850
to just specify the id
18
00:01:23,920 --> 00:01:26,950
and in this case that's going to be equal to 2.
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
20
00:01:34,150 --> 00:01:35,040
deleted.
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.
2166
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.