Basic CRUD Operation using mongoDB Compass
By: Muhammad Zain Tariq
Tags: Mongodb Compass Crud, Crud Operations, Crud In Mongodb, Mongodb Compass, Mongodb

Step by Step guide for performing CRUD operation using mongoDB Compass

In this Blog, You will Learn

What is MongoD Compass ?

CRUD operation in mongoDB using Compass.

If you can want to know about setup/installation of mongoDB you can check out my this blog Getting Start with MongoDB.

If you can want to know about CRUD operation mongoshell so check out my this blog CRUD operation mongoshell.

What is MongoD Compass ?

MongoDB Compass is the GUI for MongoDB. Compass allows you to analyze and understand the contents of your data without formal knowledge of MongoDB query syntax. In addition to exploring your data in a visual environment, you can also use Compass to optimize query performance, manage indexes, and implement document validation

CRUD operation in mongoDB using Compass

For crud operation first we will make a connection with our database for this we will open compass and first click at Fill in connection fields individually as shown in figure

and after this just click on connect as shown in figure below

now we have created connection successfully and we can see our collections at left side bar

in this blog we will be using crudpractice database with its data collection. below is the current documents present in Collection

Create/Insert operation

for create operation we will perform following steps

Step 1

select the ADD DATA option and then select insert Document

Step 2

Now Click on Second option on the view as shown in figure below

Step 3

After this we will insert name ,age and degree after each insertion we will press enter button to write next values and After that press insert button.

figure 1.

So when we check our collection and in figure 2 you can saw updated collection and this was insertion process.

figure 2.

Read in mongoDB compass

For reading a document in Compass we will just write our condition in filter box such as we need only data of name zain so will write as shown in figure 3

figure 3

Update in mongoDB Compass

updation in mongoDB compass is very simple such as we saw in above figure also that age is a integer value and it is stored as string because every new value is inserted as a string so we will change it to integer with following steps.

Step 1

We will press this edit option as shown below

Step 2

Now select the string arrow option and

Now select the int 32 and click at update option

And below is the updated documents in which you can see that age type is change from string to int32

Delete operation in mongoDB compass

now we will do delete operation in mongoDB compass as we want to delete document of name zain so we have to perform two steps only.

Step 1.

First we have to select delete option as shown in below figure

Step 2.

Just Click on Delete button as shown below

So the final version after deletion is below

Hurry! we have successfully completed CRUD operation in MongoDB compass.

Conclusion

we learned how to perform CRUD operation in MongoDB compass.

If you liked my blog follow me for further excited Blogs and if want to contact than connect on LinkedIn.