- [Instructor] On many websites, you find
a form for users to register an account and set a password.
And in this chapter, we are going to build exactly that.
To store the users we will use MongoDB
and for that we need access to a MongoDB server.
While it's easy to spin up a MongoDB server on a Linux box,
it can be hard on other operating systems like Windows.
Additionally, a production setup usually requires
at least three nodes to form a cluster.
If you don't want to set this up,
you can use a hosted solution.
For this course we will use MongoDB Atlas.
It's a hosted solution directly from the creators of MongoDB
and it offers a free tier
that is sufficient for our purposes.
So let's set this up, look up MongoDB Atlas
in a search engine and then you will end up on a page
like you see it here.
And here you will simply select get started for free
and create an account.
I already created an account and logged in.
And you should find yourself then on a page like this
where you can create a new cluster.
So I click on build a cluster and there
we will create a cluster using only the free tier options.
We can leave everything at default
and I will now click on Create cluster
and we will end up on a page that tells us
that the cluster is being created
and this will take a while.
Now that it has this ready
I want to create some databases on it.
So I click on collections
and there on create databases
and I want to create a database for production.
So call it production and I already know that we will
have a collection called users on that
and then click create.
Additionally, I also want to create a database
for test and also here
I create a collection users
and I will do the same for development.
Next, we of course also need all the credentials
in the database user to collect to this cluster.
For that I click on clusters and then on security
and first we have to whitelist our current IP
so that it's allowed to even connect to this cluster.
So I click on IP whitelist and then add IP address
and I will use my current IP address for that.
I click confirm.
And we also need a user to connect to this cluster
so I click on MongoDB users and add new user
and here I call this user dbUser
and it will auto generate a secure password.
I click on show and they will copied it out now
and click on add User and with this user in the clipboard,
I head over into my application and there
I just create a temporary file
just to preserve this password there.
Now we need the connection string to connect to this cluster
so I click on clusters and then connect,
there I choose connect your application
and we will use the newer connection string
for zero six plus drivers.
So click on that, I will copy it out
and I head again over into my application.
Paste the connection string in there
and I will replace the password placeholder
with the password restored before and also
I will change the database name
that is here mentioned in the database url
here its test I will change it first to production.
Lets remove the r here and I copy it three times,
we need production, test and development.