- remove_red_eye1475 Views
- event7 Jun 2019
- access_time3 min read
MongoDB is an open-source and leading NoSQL database. In this tutorial, we will learn MongoDB basic commands.
MongoDB is very popular NoSQL database. MongoDB stores information in a JSON format but not limited to JSON, you can also store other data formats.
Here is the common MongoDB terminolgies.
- Database – Stores collections
- Collections – similar to tables, store data.
Head over to the official MongoDB installation page and download the MongoDB installer suited for your operating system.
We can verify the installation of MongoDB by running the MongoDB shell. Open your terminal and type mongo command.
Awesome. Moving right along.
To create a new database, just type the following command.
You can run this command to validate whether the database was created or not.
Let’s create a collection.
To create a new collection, run the following command.
You can run this command to validate whether the collection was created or not.
Let’s add some data in the collection.
Adding data in the collection
You can use the insert() method to add a new data in the collection.
Awesome. Let’s search for the data we just added.
Finding the data in the collection
You can use the find() method to search for the information inside the collection.
Updating and Deleting data in the collection
You can use update() and delete() method to update or delete the information in the collection.
We learned the basic commands of MongoDB and how to use them to perform operations in MongoDB.