In this video we are going to create connection string for MongoDB to be able to interact with the MongoDB
database using our express application.
So the first step is that if you don't have an account, click on try free.
But if you have one click on sign in and I'm going to click on sign in and here I'm going to look in
using my preferred login details, I'll start.
All right.
The next step is that click on this icon to create a project for me.
I have a couple of projects that I've created, so I'll scroll down and then I'll click on New Project.
The name of this project, I'll call this one as full stack block version three, and I'll click on
next.
Next is click on Create project.
Next step is click on build a database, and here select the free tier by clicking on create.
And here you need to select your cloud provider, meaning a region that is close to you.
So I will select the default and I'll scroll down.
And for the cluster name, I would like to rename this one as full stack block version three as a name
of my project.
For this we can use any name, so I'll click on Create Cluster.
Next step is I need to provide the user.
So here I'll provide a novatek.
For the password.
I'm going to click on auto generate secured password going to be as that.
So next step is that make sure you copy the password because you may need it in the application to be
able to connect.
So I'll click on Copy.
And lastly, I'll click on Create User.
So let me get back to the application and let me pass the password here as that.
For the meantime, the next step is that we need to add the IP address, meaning which region that you
want them to use your application.
If you click on add my current IP address, meaning that only users within my region can have access
to my application.
But for this one, I want anybody on the internet to have access to the application.
So I'm going to provide a universal IP address at 0.0.0.04 zeros and I will click on Add entry.
The next step is that I'll click on finished and close and click on Go to databases and here we go.
So let's have some patience.
What it is building our cluster.
So what is building?
Let's get back to application.
And in here we are going to create a file called Dot E and V.
So at the root of the project, I'm going to create one file and this one going to be as dot E and V.
So what is the E and V file?
This file is going to contain the code that we don't want to expose to the outside world, meaning a
code that is more private for our case.
A code that is more private for now is our MongoDB connection string.
So if we expose our database connection string, it means that if a user have access to that, that
user can perform all the operation of which we are not even aware of.
In that way, we need to secure that.
So here I'm going to provide a name called Mongo.
You are l.
And it's equal to the name of our connection strength.
So here it has financed through our click on Connect and we have couple of options.
So in here we are going to use Connect your application and I'll click on this one and I'm good to go.
Lastly, I'll click on Close.
So back here, I'm going to paste that one.
So let's look at the you are here.
You can see that after first latch we have the user and this what I provided and we have a password
placeholder and you are going to use the password that I copied.
For me this is my password and for this one I will change it after this video.
So make sure that you use the exact password of yours.
So I'm going to remove this one and then paste that one here and you can see this one is the name of
the project.
And after four slash here we are going to add the custom database name.
If you don't do that, MongoDB is going to use what is called test database.
So for this I'm going to name this one as full stock block.
Next step is that we need to use this file inside the connect because you may need the connection string
here or better so we can copy this one.
And inside a deep connection string here, I will move this one and paste that.
So let's save it.
And now let's check our terminal and you can see that we have what is called DB Connect successfully.