MongoDB Atlas: Why you should start using it now?

Databases do not lose relevance. Seeking to remain positioned as the market favorite, MongoDB has released its new version, which allows you to use its service from the cloud. If you don’t know how to integrate it into your projects, here’s a short tutorial.

In previous articles, we had told you about MongoDB, and the features that position it as the most widely used Non-Relational Database (BBDD) in the world. Now and in order to continue as the market leader, MongoDB has decided to launch its own Cloud Database service, called MongoDB Atlas.

Your Database, now in the cloud

MongoDB Atlas is a Cloud Database service (or Cloud Database), which allows you to create and manage your Mongo DB from anywhere in the world, through its platform.
In addition, MongoDB Atlas is not only oriented to be accessible from the browser, but was developed with the aim of easing the work of developers, by removing the need to install and manage DB environments, which can sometimes be slow. and cumbersome.
Learning to use MongoDB has never been so easy
A wall that many developers run into when trying to learn how to use a new tool is installing it in a local environment. So, if you want to learn how to use MongoDB, MongoDB Atlas has a free-tier, which allows you to create a Mongo DB, which you can use to practice your queries, or even, since the free-tier has a space limit , but not expired, it can be used for the development of a small app.

How to use MongoDB Atlas?

To get started with MongoDB Atlas, you can access the following link; click on the “Start free” button, which will redirect you to a form for you to register; fill it out or use the option to register with Google. In both cases, it will ask you to accept its “terms and conditions”.
Upon registration, it will ask you to create an “Organization”. It can be the name of your company, company or university. The tool will use it to organize the elements of your project.
Then, give the organization a name, select the MongoDB Atlas option (if you wish, you can read its characteristics), and press “Next”.
In the next step, you can add members to your project. At the moment, we are not interested in this, so we simply click on “Create Organization”.
Once the organization is created, we will proceed to create our project. MongoDB Atlas will guide us about what our next actions are, however here we will explain the step by step.
Creating a Cluster in MongoDB Atlas
MongoDB Atlas works through Clusters, which are sets of databases, but first, we must create a project. To do this, in our dashboard, we click on “New Project”.
In the Project creation screen, we will assign a name to it -which must be unique within the organization- and we click on “Next”.
Later, it will ask us if we want to add members. Again, we’ll skip this, and click “Create Project”.
When finishing creating the Project, it will immediately send us to an interface from where we can create our first Cluster. We click on “Build a Cluster”.
Here, it will ask you to confirm some of the data pre-populated, as well as asking what programming language you intend to connect to MongoDB Atlas with. Although this step is optional, we recommend doing it to optimize the information that the platform provides you. We click on “Continue”.
Then it will ask us to select a tier. For the purposes of this tutorial, for obvious reasons, we will choose the free-tier. And we click on “Create a Cluster” in the corresponding box.
On the next page, we will be presented with various options to customize our Cluster, but since we are using the free-tier -which is a bit limited-, we will not be able to do much here, so we finish the operation by clicking on “Create cluster”.
Our Cluster will take a couple of minutes to get ready, so while we can give our machine access, local or remote, to the project in general.
Providing access to MongoDB Atlas
MongoDB Atlas has quite a few built-in security measures to prevent unwanted access to your database. One of them is IP blocking, which allows you to restrict the addresses from which you can access the database. To allow an IP address in MongoDB Atlas, from our dashboard we must click on “Network Access”, and then on “Add IP Address”.
Here, MongoDB Atlas gives you the option to add the IP address of the computer you’re from now, or even enable the option to allow access from anywhere (we don’t recommend this, or anyone who has your password will be able to access the DB). ).
We can tag this connection with some description, and it also allows us to give it an expiration. With no more changes to make, we press “Confirm”.
In addition to access by IP, we must create a user to connect to the DB from our app. To do this, we click on “Database Access”, and then on “Add New User”.
Again, MongoDB Atlas will present us with a series of options to customize our user. At the moment, we will not make any changes to the default options, and we will only add a username, password and click on “Add User”.
And now, we connect to MongoDB Atlas
To connect to our Cluster, which should already be created, we click on “Clusters” in the menu, and from here, we click on the “Connect” option.
Then, we click on “Connect your application”
Here, MongoDB Atlas provides us with an interface where we can select the programming language that our app will use to connect to Mongo. If when creating the project you had indicated this, it will come with that language selected by default.
We check the option “Include complete example of the driver code” so that it provides us with the complete code that we will need to connect.
In our code, it should look like the following image. Remember that in your project, you must install MongoDB as a dependency to use its features.
myUser is the user we created earlier, and replace by the password that we assign to that user. With this, we should have a successful connection to MongoDB Atlas.
a great value
MongoDB Atlas is a very powerful tool, useful for companies that want to optimize development times by not having to worry about DB environments.
It is also helpful for developers who want to learn about MongoDB and Non-Relational Databases, or even carry out a personal project, without having to install a whole local environment. If you find yourself exploring new tools, this may be your best alternative.

Related Posts

Leave a Reply

%d bloggers like this: