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

  1. Create a Cluster in Shared envirement.

Cluster

  1. 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.

Connect Cluster

Now you will see the String like this.

terminal

Copy
mongodb+srv://<username>:<password>@cluster0.cwjlffd.mongodb.net/
  1. 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

  2. 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

Copy
mongodb+srv://<username>:<password>@cluster0.cwjlffd.mongodb.net/todo_app

You string will be use in Envirement variables when you deploy the API on production.