1
00:00:00,330 --> 00:00:00,630
All right.

2
00:00:00,630 --> 00:00:01,530
Welcome back.

3
00:00:01,590 --> 00:00:06,510
In this lesson I'm going to introduce you to Mongo D-B which is the main database that we'll use through

4
00:00:06,510 --> 00:00:07,650
most of the course.

5
00:00:07,950 --> 00:00:11,800
And by the end of the video Our goal is to have Mongo T-P installed.

6
00:00:11,810 --> 00:00:16,860
So let's start by talking about what is Mongo D-B what type of database is it and why are we using it

7
00:00:16,860 --> 00:00:17,460
.

8
00:00:17,460 --> 00:00:25,170
I briefly mentioned this in the last video but Mongo DP is a no sequel or non-relational database so

9
00:00:25,170 --> 00:00:29,960
our data will look like this where it basically looks like javascript objects and arrays.

10
00:00:30,060 --> 00:00:32,780
Key value pairs that we store in the database.

11
00:00:33,000 --> 00:00:35,550
And that means that it's very flexible and dynamic.

12
00:00:35,700 --> 00:00:37,640
But that's not really why we're using it.

13
00:00:37,740 --> 00:00:43,590
Because to be honest with you the stuff that we're going to be doing is doable in any of the databases

14
00:00:43,680 --> 00:00:47,970
that I could have picked from and this is one of those decisions that I made where I could have gone

15
00:00:47,970 --> 00:00:54,480
either way we could have learned post-grads we could've learned Majeski Well we could have learned Mongo

16
00:00:55,140 --> 00:01:00,720
and the main reason that I decided on Mangu is that it's the most popular database right now with node

17
00:01:00,890 --> 00:01:02,200
with Express.

18
00:01:02,200 --> 00:01:07,440
There's a pretty popular stack that you might have heard of called the mean stack and that stands for

19
00:01:07,440 --> 00:01:11,280
Mongo express angular and Noad.

20
00:01:11,280 --> 00:01:14,290
So we're going to do the men stack for now.

21
00:01:14,390 --> 00:01:15,280
No angular.

22
00:01:15,540 --> 00:01:19,260
So that's Mongo Express and node and we have these two down.

23
00:01:19,320 --> 00:01:23,880
Now we need to learn about Mongo and the other reason I decided on Mongo is that it has really good

24
00:01:23,880 --> 00:01:27,150
tools right now for us to use it instead of an express app.

25
00:01:27,180 --> 00:01:32,400
So just to reiterate there were a few options of databases that we could have picked from by picking

26
00:01:32,400 --> 00:01:33,100
Mongo.

27
00:01:33,150 --> 00:01:37,610
I am not saying that you should always use Mongo that it's the best thing in the world.

28
00:01:37,650 --> 00:01:43,590
In fact it got so popular so quickly that there's been a backlash against it from a small part of the

29
00:01:43,590 --> 00:01:45,570
community in the last few years.

30
00:01:45,660 --> 00:01:47,990
And then there's been a backlash against that backlash.

31
00:01:48,060 --> 00:01:49,840
But it is somewhat controversial.

32
00:01:49,860 --> 00:01:54,870
Lots of companies are using it and it's very quickly becoming one of the most popular databases.

33
00:01:54,870 --> 00:02:00,720
It's currently the most popular no sequel database and it's the third or fourth most popular database

34
00:02:00,720 --> 00:02:01,630
in general.

35
00:02:01,980 --> 00:02:07,800
OK so before we move on to installing it let me show you the Mangu D-B home page so it's Mangu D-B dot

36
00:02:07,830 --> 00:02:08,760
org.

37
00:02:08,760 --> 00:02:10,380
You can read the docs here.

38
00:02:10,650 --> 00:02:14,700
That will explain some of the methods some of the syntax that you need to know.

39
00:02:14,710 --> 00:02:20,760
There's this university tab where they offer online courses and you can watch some of these if you're

40
00:02:20,760 --> 00:02:22,650
interested but you don't need this.

41
00:02:22,650 --> 00:02:24,190
You have another online course.

42
00:02:24,300 --> 00:02:26,370
So let's get back to installing it now.

43
00:02:26,640 --> 00:02:32,850
And what we need to do is install Mongo in our cloud nine instance and cloud nine.

44
00:02:32,850 --> 00:02:36,220
Fortunately for us has a nice set of instructions.

45
00:02:36,390 --> 00:02:37,880
So I'm going to walk you through it.

46
00:02:38,070 --> 00:02:42,600
What we need to do is run three simple commands but they are important commands.

47
00:02:42,660 --> 00:02:47,400
So I'm going to ask you to watch me do it first before you follow along.

48
00:02:47,670 --> 00:02:50,330
So this will be 30 seconds of me running commands.

49
00:02:50,550 --> 00:02:51,740
And then you should do it on your own.

50
00:02:51,750 --> 00:02:56,550
But I just want you to pay attention pretty closely because these are important what we need to do first

51
00:02:56,910 --> 00:02:59,710
is make a directory and we're going to call it data.

52
00:02:59,850 --> 00:03:03,030
And that's where Mangu is going to store all of its information.

53
00:03:03,240 --> 00:03:05,920
So we need to make the directory so you can see here.

54
00:03:06,420 --> 00:03:12,180
And then we need to tell Mangu that that data directory is where it should store all the data and when

55
00:03:12,180 --> 00:03:16,080
to tell it where that directory is which is what this command does.

56
00:03:16,350 --> 00:03:18,560
You don't need to worry about what exactly it does.

57
00:03:18,570 --> 00:03:20,270
You can read more here.

58
00:03:20,880 --> 00:03:26,700
But again it just is telling Mangu to use our new data directory and then we have to run this third

59
00:03:26,700 --> 00:03:32,040
command here which will help change some of the permissions and settings so that things work smoothly

60
00:03:32,030 --> 00:03:32,540
.

61
00:03:32,610 --> 00:03:38,550
So I'm going to go ahead and run that however I'm going to move into a new directory and the directory

62
00:03:38,550 --> 00:03:45,000
I'm going to go into is actually outside of this main web dev boot camp directory.

63
00:03:45,000 --> 00:03:53,010
So right now if I in my terminal can see I'm on the workspace I'm actually going to see one more level

64
00:03:53,010 --> 00:03:59,580
out or now I see my workspace and I don't have to do this I can install this data directory anywhere

65
00:03:59,880 --> 00:04:04,770
but I'm going to put it outside just so that you don't accidentally deleted we don't accidently mess

66
00:04:04,770 --> 00:04:06,220
with it at any point.

67
00:04:06,310 --> 00:04:12,090
So we're going to do that now and make directory data makes this a little bit bigger.

68
00:04:13,440 --> 00:04:19,710
And our clear everything and make sure we see the data directory and then I'm going to copy this line

69
00:04:21,420 --> 00:04:28,850
and paste that in and hit enter and then the very last thing is running.

70
00:04:28,850 --> 00:04:32,480
This line here just like that.

71
00:04:32,850 --> 00:04:34,050
OK.

72
00:04:34,190 --> 00:04:39,060
Now if we go back to the instructions you can see that we've finished the three commands that we needed

73
00:04:39,060 --> 00:04:40,150
to run.

74
00:04:40,380 --> 00:04:42,330
And now we have Mongo installed.

75
00:04:42,450 --> 00:04:48,750
So all we have left to do is actually start Mongo and we to start what is called the Mongo deman which

76
00:04:48,750 --> 00:04:53,430
is basically a process that is going to start Mongo and we're going to keep it running in the background

77
00:04:53,490 --> 00:04:55,670
for the rest of the course.

78
00:04:56,280 --> 00:05:03,150
And the command to do that looks like this dot slash Hmong God which is Mongo demon.

79
00:05:03,270 --> 00:05:05,100
So we'll go back.

80
00:05:05,100 --> 00:05:09,060
We need to run this in the directory where we see Man-God.

81
00:05:09,060 --> 00:05:13,700
It's the same directory where we installed data and then we'll just paste that commanded.

82
00:05:14,430 --> 00:05:16,540
And you should see a bunch of text.

83
00:05:17,010 --> 00:05:19,910
And this is the Mongo server that's now started.

84
00:05:20,070 --> 00:05:23,390
So it's a process that we started with this command right here.

85
00:05:23,760 --> 00:05:25,860
And then what we'll do is we'll leave this running.

86
00:05:25,860 --> 00:05:29,700
So I'm actually going to leave this tab open and make a new tab.

87
00:05:29,850 --> 00:05:35,280
You can do that here plus sign new terminal and this is where we'll work inside of it for most of the

88
00:05:35,280 --> 00:05:35,890
course.

89
00:05:35,940 --> 00:05:40,440
We won't touch this because we want our database to always be running so that we can always connect

90
00:05:40,440 --> 00:05:41,570
to it.

91
00:05:41,580 --> 00:05:42,980
So let's try it now.

92
00:05:43,130 --> 00:05:47,540
There's a simple test we can type the word Mongo and hit enter.

93
00:05:48,300 --> 00:05:53,140
And if our prompts changes which it does that means that everything's working just fine.

94
00:05:53,480 --> 00:05:59,250
And what we just did here by typing Mangu and hitting enter is we opened up the Mongo D.B shell or the

95
00:05:59,250 --> 00:06:05,460
Mongo console which is a place we can go to interact with our data to debug things just like the javascript

96
00:06:05,460 --> 00:06:08,910
console is a place we can debug but it's not where we actually work.

97
00:06:08,910 --> 00:06:10,690
Most of the time.

98
00:06:10,950 --> 00:06:12,590
So that's all we'll do for now.

99
00:06:12,600 --> 00:06:16,870
Make sure you have this Mongo daemon running in the background at all times.

100
00:06:16,920 --> 00:06:20,070
If it ever stops it gets accidently stopped it.

101
00:06:20,070 --> 00:06:22,140
I can just run that command again.

102
00:06:22,410 --> 00:06:26,470
But I do need to make sure I'm in the right directory where we created that data folder.

103
00:06:26,580 --> 00:06:30,620
So leave this running open up a new tab and that's it for now.

104
00:06:30,630 --> 00:06:34,890
In the next lesson I'm going to show you how you can start writing some Mongo code to interact with

105
00:06:34,890 --> 00:06:37,890
the database add things and remove them.

106
00:06:37,890 --> 00:06:39,040
Read them back out.

107
00:06:39,060 --> 00:06:40,410
All that fun stuff.

108
00:06:40,440 --> 00:06:41,390
All right I'll see you then.
