MongoDB
What is MongoDB
MongoDB is an No SQL and open source database, this is more popular due to its speed , easy to use and scalability. In MERN stack projects MongoDB act as a database. similar to SQL database we can use MongoDB to insert ,Find, Retrieve data ,Update and Delete data
Difference between RDBMS and MongoDB
Advantages of MongoDB
· Schema less − MongoDB is a document database in which one collection holds different documents
· Structure of a single object is clear.
· No complex joins.
· Deep query-ability. …
· Tuning.
· Easy to use
Documents
Documents are like rows in SQL databases. When creating we must use JSON format. We can create any number of documents inside a collection and there can be different values inside a document. Inside a document, we can store a key-value pair and other attributes with their values. Documents are written inside the curly brackets and Documents don’t follow any order
- Inserting a row to the user
2. Inserting many rows to the users
3. Finding a user
4. Updating age in the user
Creating a MongoDB database (Atlas cloud)
MongoDB Atlas provides an easy way to host and manage your data in the cloud.
Steps to create
1. Create an Atlas Account
2. Deploy a free tier Cluster
3. Add your Connection IP Address to your IP Access list
4. Create a Database User for your Cluster
5. Connect to your Cluster
6. Insert and View Data in your Cluster
2. Deploy a free tier Cluster
Under that dashboard, we have to press “Create a new cluster button” to create a new cluster and fill the respective fields .
3. Add your Connection IP Address to your IP Access list
- Under that dashboard, we have to press “Network Access button” to create a Connection.
- Click on Add IP Address in the top-right corner. This will open the Add IP Whitelist Entry dialog.
- Click on Add current IP address
4.Create a Database User for your Cluster
Under that dashboard click on “Database Access” > “Add new database user”: Enter a username and a strong password.
5.Connect to your Cluster
Inside the Clusters window, click the Connect button. => “connect your application”