By Hemanta Sundaray on 2021-05-23
Creating a MongoDB Atlas account
When a user submits the registration form, we will send the user details to the server and save them in a database.
We will use MongoDB, which is a document database. In MongoDB, databases hold one or more collections of documents.
Collection: Collections are analogous to tables in relational databases. Each record in a MongoDB collection is a document.
Document: MongoDB stores data records as BSON documents, which are binary representations of JSON documents. MongoDB documents have similar structure to JavaScript objects and are composed of field-value pairs. MongoDB does not require that all documents have the same structure.
We will be using MongoDB Atlas (cloud based database-as-a-service) free tier to provide the database. This makes the “installation” operating system independent. I also use it as my production database for www.sundaray.io.
First, we will create an account on MongoDB Atlas, which is a fully-managed cloud database developed by the same people that build MongoDB.
Go ahead and register for a new Atlas account at the following link.
https://account.mongodb.com/account/register
You can register for an Atlas account using your Google account or email address.
During the registration process, MongoDB will ask you to set an organization name and a project name.
An organization can contain multiple projects. By having multiple projects within an organization, you can isolate different environments (for instance development/production) from each other.
By using the FREE TIER, the default setup is to deploy a MongoDB cluster with a replica set.
What are clusters in MongDB?
In the context of MongoDB, the word cluster either refers to a replica set or a sharded cluster.
A replica set is the replication of a group of MongoDB servers that hold copies of the same data, thereby ensuring high availability and redundancy, which are crucial features to have in place in case of failovers and planned maintenance periods.
A sharded cluster is commonly known as horizontal scaling, where data is distributed across many servers.
What is MongoDB Atlas Cluster?
MongoDB Atlas cluster is a NoSQL Database-as-a-service offering (available in Microsoft Azure, Google Cloud Platform, Amazon Web Services). You don’t need to install any software as you can connect to MongoDB directly from the web user interface.
When you deploy your application, you would want everyone to access your application.
What is an IP address?
Any computer linked to a network has a unique address that identifies it, called an IP (Internet Protocol) address. It’s an address made up of a series of four numbers separated by dots (for example127.0.0.1) and represents a unique location on the web.
You must create a database user to access your cluster. For security purposes, Atlas requires clients to authenticate as MongoDB database users to access clusters.
Database users are different from Atlas users:
Set the Username & Password. You should store the password somewhere safe; we will need the password later.
In the clusters view, click on COLLECTIONS.
Give your database a name. You will also have to specify the name of your collection. Note that the name of the collection you specify here does not really matter. We will manage the names of collections from mongoose. Moreover, if you specify a name that you don’t plan to use, you can simply delete it from the dashboard.
Click on Create and MongoDB will create our database. We will need the database name later.
With this, our MongoDB Atlas configuration is complete.
Go to part-7