In the last section we had a quick discussion about mongoose and Lango DVH.
We're now going to continue by setting up a mongo DV database and wiring it together with our express
application.
Now in general there's two different ways that you can get longer to be running for your own personal
projects.
You can either install a local copy so like install a copy of Mago D-B onto your own personal laptop
or desktop or you can use a remotely hosted instance.
Now in this course we're going to use the latter.
We're going to use a remotely hosted instance of Mongo DVH.
The reason for that is that it is far easier to install Mongo D-B or to get a copy of it running when
it is remotely hosted.
Trust me I have helped people install and troubleshoot Mongo installations for a long time now and it
can be a real pain in the rear.
Sometimes it goes really well but sometimes it can be a pain in the rear.
So in this course we're going to use a outside service or a third party service to host a copy of Mongo
divi for us.
So on this remote service somewhere out on the internet we will have our running Mongo DB copy and then
on our own local computer.
We will continue to have our express API and pretty soon we will also have our re-act application as
well.
Now of course this is talking about power application is set up for our development environment and
this entire process works just a little bit differently with Heroku.
By the way as soon as we finished wiring up all this Mongo DB stuff and we finish up the authentication
piece we will then redeploy our application up to Trochu and get an updated copy up there.
OK so let's get to it.
We're going to now create a remotely hosted copy of Mongo to do so.
I'm going to open up a new tab inside my browser and navigate to in lab dot com him.
As in like Mongo.
I guess now once you come here if you've never signed up for in lab before you'll want to go to the
sign up button right here and create a brand new account absolutely no credit card is required to sign
up for in lab or created a mongo DB database which makes in lab a really great place to get started.
Now once you have created your account you'll want to log in and I'm going to do that right now and
then after you sign in you'll be dumped at a dashboard that lists all of your different running Mongo
D-B deployments and so these are a couple other copies among OODB that have running on this kind of
test account right here.
So chances are you don't see any of this right now because you might have never created a database previously.
So to create a new database going to find the create new button over here will click it and it will
be taken into a creation wizard.
Never going to be immediately asked on what plan type we want so we can pick free $15 or a hundred and
eighty and I'm going to let you guess which one we want.
Yes we want the free ones are in a pick sandbox right now.
Google club platform and Microsoft azer.
If you want to go with these different providers you certainly can feel free to do so.
But Amazon Web Services is totally fine.
Totally appropriate for what we're doing.
So we're going to pick a sandbox on AWOS.
Now once we selected we'll continue down here.
And then you will pick a region to host your database in.
So once you are using or when you are using the free copy like we are you either get to pick from the
EU or from US East.
So just pick whichever one is closer to you.
If you are off continent somewhere that is totally fine.
Just pick either one.
It doesn't really make a big difference.
So going to pick us East because I'm in the US.
Click Continue.
And then finally we need to enter a database name.
So for us we're going to use a database name of email the dash DEP like so and then for the database
version you can just leave it at whatever the default is.
If you see a newer version here that's totally fine.
Don't sweat it.
So we'll continue.
We'll submit the order and that is pretty much it.
So pretty painless especially compared to hosting your own local copy.
Believe me.
Now unfortunately there is one last step that we have to go through but it is still pretty painless.
So let's do it right now.
You should see a new database pop up on your Mongo DB deployment list right here.
And so here's mine.
Email the dash dev.
So I'm going to expand it.
And I get taken to the dashboard for this database now immediately you'll see that we do not have any
collections.
So we have no records whatsoever.
We will also see two quick notifications on here.
The first one is hey this is not really suitable for production.
Ok whatever.
And then the second one is a little bit more relevant to us.
It says a database user is required to connect to this database.
So this is something that we have to do to use this database at all.
Now to be really clear I'm going to spell this out and make sure it is crystal clear in our application.
We're going to have users write people who like to sign into our application.
Those users will be stored in a user's collection.
So we're going to have a collection called users and it will have all the different people who sign
up for application.
A user that this notice right here is talking about is a data base user it is an account that is used
to access the Mongo DVH database.
So these are two completely separate users.
One is a user inside of our application who is like going through the process.
The other is the other is like an administrative account or a service account that we are using to access
and modify this database.
So two separate sets of users.
And I'm sorry if I seem really extreme as I say this but many people in the past have been very confused.
So I just want to spell it out and make sure it's crystal clear.
OK.
Let's do it.
We're going to find the users button.
Here it is right here.
Click it and then I'll find the button over here that says ad database user.
So we are now prompted to enter in a database username and a database password.
Now these are entries that you will probably want to use something reasonably secure.
Do remember that this is a development are kind of like a test database.
It's not going to host our production data at the end of the day.
So you know do something reasonably secure.
But for me I'm going to keep it easy.
I was going to do this username of username you know actually let's do something a little bit more clear
than that.
Let's do this Steven.
Why not my name and then I'm going to use a password of just password and keep it really easy and really
straightforward and then make sure that Read-Only is not checked.
We do not want this to be a read only account.
So finally we'll click Create at the bottom and that's pretty much it.
So we should now see on this user's tab one database user.
This is the name of the account.
It is not a read only account so it should say false right there.
And we now have a database account or a database user that can be used to access and modify our Mongo
divi instance.
OK.
So that really truly is it for our IN lab setup.
We're now going to take a break.
When we come back we're going to install mongoose on our express API and then we're going to instruct
mongoose how to connect to this particular copy of Mongo D-B that we just set up.
So all Catcher in the next section.