And once we're familiar with MongoDB, let's set up and configure MongoDB Atlas so we can host and manage
our data in the cloud.
I have the account already, but since I want to cover all the steps in detail, I'll set up another
dummy account together and remember, we can set up the entire thing for free.
So don't worry, your credit card can stay nicely tucked away in your wallet if you get stuck or confused
in any of the steps we're about to take.
Here is an awesome resource you can use.
Just go create MongoDB Atlas and follow this link, which actually brings us to official docs.
And here you'll find a checklist which we're going to use as our roadmap for the following few videos.
And what is the first thing they want us to do?
Create a new account.
So let's do this, people.
I'm going to open this up in new tab and then of course you can find a bunch of useful info on here,
yada, yada, yada.
You keep on scrolling.
And I actually want to navigate to a login page and I'm just going to pretend that I don't have the
account and we're going to go for signup.
And here, of course, you just need to provide all the necessary info.
And once you have filled everything out and as a side note, don't worry, this is not my real phone
number.
Then of course, just click on signup.
And up next, they're going to ask for organization and project name.
And in my case, I'm going to go with Node.
Express course.
Then I'll pick JavaScript, we'll click on continue and we probably can actually skip this, but let's
just leave it there and add up.
Next, they want us to set up the cluster.
Now if you take a look at the checklist, actually cluster is already second step.
So let's go back here and pretty much you always want to show for two, three, one, unless of course,
you want to start paying them.
So and here we'll just go with create cluster that's going to be the free one.
Then it's using a was awesome as far as region, I'm going to go with this one and then we have cluster
tier and additional settings and we'll leave them both as default.
And lastly, I just want to change the name and I think I'm going to go with Node Express and Project,
and once we're done, we just need to click on Create Cluster and we'll get ourselves a new cluster.
Now, as you can see over here, they say that it's going to take a little bit of time, which is usually
the case.
So I'll stop the video here and I'll see you in the next one where we'll continue with our steps.
And once our cluster is ready to go before we start messing around with data.
So with collections and documents and all that, there's a few things that I want to do first, and
I'm going to start by setting up the database access.
So effectively in here we'll set who can access our database.
Now, I'm not talking about the Atlas account.
No, I'm talking about the database and collections we're about to set up, and we simply need to click
on add new database user and we're going to go with password.
And if you get some default values, just wipe them clean.
And I'll simply go with John.
And as far as the password, I'm just going to go with one, two, three for please, please, please
do not do that in your own setup.
The only reason why I'm doing that, because you'll be able to see my password anyway.
And don't worry, once I'm done setting up this project, of course I will change my password.
So it's not going to be one, two, three, four.
And once you're done with the user and password notice we have database user privileges and less user
can read and write to any database.
So I'll leave it the way it is and add a new user.
That's good.
I'll close this one.
A quick update.
Since I recorded this video, a setup for read and write privileges is a little bit different and it's
very easy to kind of skip that.
And you'll have the bugs later when you try to connect to Atlas from your local application.
So let's say you want to create a new user.
In my case, I'm going to go.
Beta going to auto generate a secure password.
So this is what they give me.
And notice how in the video automatically the reading right was added, right there was the select box.
In this case we need to go with add built in row if you'll save basically, if you'll add this user
without selecting this, that's when you will get those box when you try to connect from your local
application.
Back to the atlas, even though your password is going to be correct and username and all that, if
you don't set this at all, yes, you'll get the bug.
So therefore click here on ADD built in row and then you select the URL whether it's going to be an
admin, read and write or only read.
So in my case I'm going to go with, read and write and then we save.
After that, everything is exactly the same as I show in the video.
Just make sure that you click on that add built in roll.
And then we want to set up the network access.
So we want to set up from where we can access our database.
And you can imagine that, of course, once we deploy the project, that of course will set up that
IP address.
But for the time being, while we work locally, we might as well set up access from anywhere.
Now, if you want, you can set up your own IP address here so you can just add the current one.
But in my case, I'm going to go allow access from anywhere and I'll just click on confirm.
And lastly, I want to get the connection string that we're going to use once we connect our database
to our application.
And in here, what you're looking for is connect.
So you want to go back to the cluster, then connect and then you want to go with connect your application.
So not the Kompass one, not the Mongo shell.
Actually the second one here, connect your application and then I'm going to go with 3.6 or later.
That's about right.
And then you just want to copy this one and then navigate back to our project.
A quick update.
At this point, Atlas does not provide the default database name anymore, so instead of my first database,
now the connection string looks like this.
Where the value between MongoDB dot net and question mark is simply empty.
Now, it's not a big deal.
Just add your own database name.
Once the connection string is in your text editor again, let me repeat.
Everything else stays the same.
Just the default database name is missing from the connection string.
So we need to add it by ourselves.
Now, eventually we'll set it up as the environment variable.
Yes, that's going to be the case.
But for the time being I'll simply create a new folder in the starter and I'll call this DB.
And then instead of the DB there's going to be a new file and I'll call this connect JS and then I want
to create a new variable and I'll call this connection string and I'll set it equal to that value.
Now we'll have to add some values over here, but we'll do that later once we're actually ready to connect
our application to the database.
So just take the string.
Copy and paste, set it up in the DB and then connect.
Jess And now we can start exploring the Atlas setup.