All right.
Welcome back.
In this lesson I'm going to introduce you to Mongo D-B which is the main database that we'll use through
most of the course.
And by the end of the video Our goal is to have Mongo T-P installed.
So let's start by talking about what is Mongo D-B what type of database is it and why are we using it
.
I briefly mentioned this in the last video but Mongo DP is a no sequel or non-relational database so
our data will look like this where it basically looks like javascript objects and arrays.
Key value pairs that we store in the database.
And that means that it's very flexible and dynamic.
But that's not really why we're using it.
Because to be honest with you the stuff that we're going to be doing is doable in any of the databases
that I could have picked from and this is one of those decisions that I made where I could have gone
either way we could have learned post-grads we could've learned Majeski Well we could have learned Mongo
and the main reason that I decided on Mangu is that it's the most popular database right now with node
with Express.
There's a pretty popular stack that you might have heard of called the mean stack and that stands for
Mongo express angular and Noad.
So we're going to do the men stack for now.
No angular.
So that's Mongo Express and node and we have these two down.
Now we need to learn about Mongo and the other reason I decided on Mongo is that it has really good
tools right now for us to use it instead of an express app.
So just to reiterate there were a few options of databases that we could have picked from by picking
Mongo.
I am not saying that you should always use Mongo that it's the best thing in the world.
In fact it got so popular so quickly that there's been a backlash against it from a small part of the
community in the last few years.
And then there's been a backlash against that backlash.
But it is somewhat controversial.
Lots of companies are using it and it's very quickly becoming one of the most popular databases.
It's currently the most popular no sequel database and it's the third or fourth most popular database
in general.
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
org.
You can read the docs here.
That will explain some of the methods some of the syntax that you need to know.
There's this university tab where they offer online courses and you can watch some of these if you're
interested but you don't need this.
You have another online course.
So let's get back to installing it now.
And what we need to do is install Mongo in our cloud nine instance and cloud nine.
Fortunately for us has a nice set of instructions.
So I'm going to walk you through it.
What we need to do is run three simple commands but they are important commands.
So I'm going to ask you to watch me do it first before you follow along.
So this will be 30 seconds of me running commands.
And then you should do it on your own.
But I just want you to pay attention pretty closely because these are important what we need to do first
is make a directory and we're going to call it data.
And that's where Mangu is going to store all of its information.
So we need to make the directory so you can see here.
And then we need to tell Mangu that that data directory is where it should store all the data and when
to tell it where that directory is which is what this command does.
You don't need to worry about what exactly it does.
You can read more here.
But again it just is telling Mangu to use our new data directory and then we have to run this third
command here which will help change some of the permissions and settings so that things work smoothly
.
So I'm going to go ahead and run that however I'm going to move into a new directory and the directory
I'm going to go into is actually outside of this main web dev boot camp directory.
So right now if I in my terminal can see I'm on the workspace I'm actually going to see one more level
out or now I see my workspace and I don't have to do this I can install this data directory anywhere
but I'm going to put it outside just so that you don't accidentally deleted we don't accidently mess
with it at any point.
So we're going to do that now and make directory data makes this a little bit bigger.
And our clear everything and make sure we see the data directory and then I'm going to copy this line
and paste that in and hit enter and then the very last thing is running.
This line here just like that.
OK.
Now if we go back to the instructions you can see that we've finished the three commands that we needed
to run.
And now we have Mongo installed.
So all we have left to do is actually start Mongo and we to start what is called the Mongo deman which
is basically a process that is going to start Mongo and we're going to keep it running in the background
for the rest of the course.
And the command to do that looks like this dot slash Hmong God which is Mongo demon.
So we'll go back.
We need to run this in the directory where we see Man-God.
It's the same directory where we installed data and then we'll just paste that commanded.
And you should see a bunch of text.
And this is the Mongo server that's now started.
So it's a process that we started with this command right here.
And then what we'll do is we'll leave this running.
So I'm actually going to leave this tab open and make a new tab.
You can do that here plus sign new terminal and this is where we'll work inside of it for most of the
course.
We won't touch this because we want our database to always be running so that we can always connect
to it.
So let's try it now.
There's a simple test we can type the word Mongo and hit enter.
And if our prompts changes which it does that means that everything's working just fine.
And what we just did here by typing Mangu and hitting enter is we opened up the Mongo D.B shell or the
Mongo console which is a place we can go to interact with our data to debug things just like the javascript
console is a place we can debug but it's not where we actually work.
Most of the time.
So that's all we'll do for now.
Make sure you have this Mongo daemon running in the background at all times.
If it ever stops it gets accidently stopped it.
I can just run that command again.
But I do need to make sure I'm in the right directory where we created that data folder.
So leave this running open up a new tab and that's it for now.
In the next lesson I'm going to show you how you can start writing some Mongo code to interact with
the database add things and remove them.
Read them back out.
All that fun stuff.
All right I'll see you then.