4.2 MongoDB Verification
Last updated
Last updated
MongoDB is the database used in our project. It is a modern and flexible database system that stores data in a format similar to JSON documents.
The reason for using MongoDB in our project is its flexibility and scalability. It allows us to store and retrieve data in a way that suits our project's needs. MongoDB's document-oriented structure makes it easy to work with data that varies in structure and doesn't require a fixed schema.
Create a MongoDB account or Log in to MongoDB. Below are the given links for Sign up and Log In.
Signup: https://www.mongodb.com/cloud/atlas/register
Login: https://account.mongodb.com/account/login
After logging in for the first time, kindly complete the Initial setup by adding details like ‘Not Sure’ as shown in the image below.
NOTE: do not create a cluster, It will be created automatically in the process.
Now, click on the ‘Project Settings’ as shown in the image below.
After that, copy the project ID as shown in the image below and add it to the MONGODB_PROJECT_ID in the form field.
Click on the ‘Access Manager’ tab in the sidebar, select the API Keys tab, and then click on the ‘Create API Key’ button as shown in the image below.
Now, add ‘Description’ for your API key (You can add anything in the description.). Following that, select all the ‘Project Permissions’ from the dropdown and click on the ‘Next’ button as shown in the image below.
You get a public key and a private key as shown in the image below. Add MONGODB_PROJECT_PUBLIC_API_KEY which you get from ‘MongoDb Project Public Key’. Add MONGODB_PROJECT_PRIVATE_API_KEY which you get from the ‘MongoDb Project Private Key’
Now, click on the ‘Done’ Button.
Now submit all the values gathered in the installation form.
Now fill in the cluster name and select the cluster region as provided in the image below.
NOTE: the cluster created from here will be a free-tier cluster. You can upgrade your cluster later.
After the Cluster is created successfully, you will be shown form fields as per the below image.
For these fields, you need to create an App in the app services in MongoDB Atlas by following the provided steps:
Go to the MongoDB Atlas on your browser and then click on the Goto tab in the sidebar.
Then press the Tab
key, and it will show a list of options.
From the options type apps
and submit, which will take you to the apps page.
Now click on Create New App
and then fill in the details and click Create App Service
.
Now go to the Functions
tab by clicking Functions
in the left sidebar. On visiting the functions tab, create a new function.
Now provide a name for the function, and then click on the Function editor
and then paste the below-provided code in the function and click Save Draft
.
NOTE: you need to replace the DOMAIN_URL
with your URL
including the protocol (http | https).
Now go to the Authentication
tab and then click on edit for Email/Password
.
Now do the following steps:
1. Enable the Authentication
2. Select the Automically confirm the user
3. Select the Run a password reset function
and select the created function here.
4. Click on Save Draft
and then Review Draft and Deploy
.
The app is now created and you can copy the app ID shown in the image below and add it to MONGO_APP_ID in the form field. Add MONGODB_APP_ID from the URL in the header to the form field, and then submit it.