Mongodb company has a Cloud database of MongoDB, and they also offer a free tier.
Signup here and create a account → https://www.mongodb.com/atlas
- Create a Cluster in Shared envirement.
- When your cluster is ready, it will appear like this. Click on the Connect button to obtain the MongoDB URI. Then, select the MongoDB for VS Code option.
Now you will see the String like this.
terminal
Copymongodb+srv://<username>:<password>@cluster0.cwjlffd.mongodb.net/
-
Now you have to create a user for to access the database.. To do that go to Database Access and click on button Add new database uer
-
Enter user_name, password, and Select Built-in Role for Read and Write to any database
Now update your URI string with the username and password. Also, you have to append the database name at the end of the string.
Let's use database name todo_app
terminal
Copymongodb+srv://<username>:<password>@cluster0.cwjlffd.mongodb.net/todo_app
You string will be use in Envirement variables when you deploy the API on production.