1
00:00:02,480 --> 00:00:04,290
Now, the last missing piece of course,

2
00:00:04,290 --> 00:00:06,220
is how we can delete documents.

3
00:00:06,220 --> 00:00:08,680
And that's all rather straightforward.

4
00:00:08,680 --> 00:00:11,670
Let's say we want to delete this second document.

5
00:00:11,670 --> 00:00:14,810
For this, we can execute DB, then of course

6
00:00:14,810 --> 00:00:17,200
the collection name that holds the document

7
00:00:17,200 --> 00:00:18,800
that should be deleted.

8
00:00:18,800 --> 00:00:23,149
And then there, we got the delete one or delete many

9
00:00:23,149 --> 00:00:25,350
methods that we can execute

10
00:00:25,350 --> 00:00:28,770
and the commands do what their names suggest.

11
00:00:28,770 --> 00:00:32,570
Delete one will delete the first matching document,

12
00:00:32,570 --> 00:00:35,630
even if your condition would match multiple documents.

13
00:00:35,630 --> 00:00:39,163
Delete many will delete all matching documents.

14
00:00:40,210 --> 00:00:42,510
Here I only want to delete one,

15
00:00:42,510 --> 00:00:46,290
and then you pass in one parameter value where you again

16
00:00:46,290 --> 00:00:50,180
have the same filtering syntax as you saw before.

17
00:00:50,180 --> 00:00:52,730
For example, looking for an ID

18
00:00:52,730 --> 00:00:57,340
where we actually are looking for this ID now,

19
00:00:57,340 --> 00:01:01,980
this time for real, so I'll just insert this between quotes

20
00:01:01,980 --> 00:01:04,879
inside of object ID, and hit enter.

21
00:01:04,879 --> 00:01:07,670
Again, we get a confirmation where we also

22
00:01:07,670 --> 00:01:10,430
see how many documents were deleted.

23
00:01:10,430 --> 00:01:14,780
And now with that, if I then find all my restaurants

24
00:01:14,780 --> 00:01:17,630
thereafter, there is only one document left

25
00:01:17,630 --> 00:01:20,223
in there because I deleted the other one.

26
00:01:21,820 --> 00:01:24,920
And that's how we can perform those crowd operations

27
00:01:24,920 --> 00:01:27,680
on MongoDB or with MongoDB

28
00:01:27,680 --> 00:01:31,350
with this MongoDB query language,

29
00:01:31,350 --> 00:01:36,260
which as you can tell is quite different compared to SQL,

30
00:01:36,260 --> 00:01:38,710
but which hopefully still makes a lot of sense

31
00:01:38,710 --> 00:01:41,020
and is easy to get into.

32
00:01:41,020 --> 00:01:44,150
And you here also see the difference between tables

33
00:01:44,150 --> 00:01:47,700
and collections and having a fixed structure,

34
00:01:47,700 --> 00:01:49,430
a clearly defined structure

35
00:01:49,430 --> 00:01:52,530
and having no clearly defined structure.

36
00:01:52,530 --> 00:01:55,980
With MongoDB, the collections are created on the fly

37
00:01:55,980 --> 00:01:58,060
once we start inserting data,

38
00:01:58,060 --> 00:02:00,380
and we can add different documents,

39
00:02:00,380 --> 00:02:02,060
even though we didn't do that here,

40
00:02:02,060 --> 00:02:04,393
into the same collection if you wanted to.

41
00:02:05,270 --> 00:02:07,530
So, therefore these are the basics.

42
00:02:07,530 --> 00:02:11,440
Now, before we explore how we can use MongoDB with node

43
00:02:11,440 --> 00:02:13,950
and express in the next course section,

44
00:02:13,950 --> 00:02:16,930
let's first of all go back to that restaurants

45
00:02:16,930 --> 00:02:20,380
reviews example and see how we would complete this

46
00:02:20,380 --> 00:02:22,770
in the MongoDB world and how we would

47
00:02:22,770 --> 00:02:24,613
structure our data there.

