Day 22: MongoDB CRUD Operations using Compass
In the last lesson, we installed MongoDB and MongoDB Compass, and created our first database.
Now, it’s time to learn the most important part of databases: CRUD operations.
👉 CRUD means:
C → Create (Insert new data)
R → Read (Get/Find data)
U → Update (Modify data)
D → Delete (Remove data)
Let’s understand each one in MongoDB Compass with a real-life example: a Notes Application.
1. Create (Insert Documents)
When we want to add new data into our database, we use Insert.
Example: Inserting Notes
Steps in Compass:
Open Compass → connect to
mongodb://localhost:27017Create a Database → name:
notesAppCreate a Collection → name:
notesClick on
Insert DocumentAdd this JSON:
{
"title": "Shopping List",
"description": "Buy milk, bread, and eggs",
"date": "2025-08-19"
}
Click Insert ✅
Your first note is saved.
👉 You can insert multiple documents (notes), for example:
{
"title": "Study Plan",
"description": "Revise Node.js and MongoDB",
"date": "2025-08-20"
}
Now you have 2 notes in your database.
2. Read (Find Documents)
Reading data is the most common operation.
In Compass, this is done using the Filter bar.
Example: Find Notes by Title
Go to the
notescollection.In the Filter bar, type:
{ "title": "Shopping List" }
👉 This will return only the note with the title "Shopping List".
Example: Find Notes After a Specific Date
{ "date": { "$gt": "2025-08-19" } }
Here:
$gtmeans “greater than” (only notes with date after 2025-08-19 will appear).
👉 MongoDB has many query operators like $lt (less than), $in (check multiple values), $regex (search by pattern).
3. Update (Modify Documents)
Sometimes you need to update data, like correcting spelling or changing values.
Example: Updating a Note’s Description
Select the note with title
"Shopping List".Click on Edit Document.
Change description from:
"Buy milk, bread, and eggs"
to
"Buy milk, bread, eggs, and butter".Click Update ✅
Example: Bulk Update Using Filter
Suppose you want to add a new field priority to all notes.
In Compass, click Filter → leave it empty to target all documents.
Click on Update Many → add:
{ "$set": { "priority": "high" } }
👉 Now, every note will have a priority field with the value "high".
4. Delete (Remove Documents)
If you no longer need some data, you can delete it.
Example: Delete One Note
In the
notescollection, click on the note with"title": "Shopping List".Click on Delete Document.
Confirm → Note deleted ✅.
Example: Delete Multiple Notes
- In the Filter bar, type:
{ "priority": "high" }
- Click on Delete Many → All notes with
"priority": "high"will be removed.
⚠️ Be careful with Delete Many — once deleted, data cannot be restored unless you have a backup.
5. Real-Life Analogy
Think of a Notebook 📒:
Create = Writing a new note on a blank page
Read = Opening your notebook and reading notes
Update = Editing or correcting something in your note
Delete = Tearing out a page from your notebook
MongoDB CRUD works exactly like this, but in digital form.
6. Summary
Create → Add new documents using
Insert.Read → Use the
Filterbar to find documents.Update → Use
Update OneorUpdate Manyto change data.Delete → Remove unwanted documents using
Delete OneorDelete Many.
With MongoDB Compass, you can perform CRUD operations visually without writing code. This is great for beginners, but also very useful for professionals who want to quickly test queries.
📌 FAQ Section – MongoDB Compass
1) Kya MongoDB Compass ek DBMS hai?
👉 No. MongoDB Compass is not a DBMS.
MongoDB itself is the DBMS (Database Management System).
Compass is just a GUI (Graphical User Interface) tool to make it easy to work with MongoDB.
So, Compass is like a “remote control” for your MongoDB database.
2) Kya MongoDB Compass ka alternative bhi available hai?
👉 Yes, Compass ke alternatives available hain, jaise:
Robo 3T (RoboMongo)
NoSQLBooster
Studio 3T (paid, professional tool)
But for beginners, MongoDB Compass is the best choice because it is official and free.
3) Kya hum MongoDB database ko direct access kar sakte hain without GUI (like MongoDB Compass)?
👉 Yes, absolutely!
MongoDB ko direct access karne ke liye GUI ki zaroorat nahi hoti.
You can use the MongoDB Shell (
mongosh) → yeh ek command-line tool hai.You can also use programming languages (like Node.js, Python, Java) with official drivers.
So, Compass sirf ek “helper tool” hai. Aap bina Compass ke bhi MongoDB use kar sakte ho.
4) Kya MongoDB Compass only Node.js ke liye use kiya jata hai ya other languages ke liye bhi?
👉 MongoDB Compass language-specific nahi hai.
Compass ek general GUI tool hai jo MongoDB ke sath kaam karta hai.
Aap Node.js, Python, Java, PHP, C#, Go … kisi bhi programming language ke saath MongoDB use karo, Compass kaam karega.
So, Compass sirf MongoDB ke liye hai, na ki sirf Node.js ke liye.
5) MongoDB, MongoDB Compass aur MongoDB Atlas me kya difference hai?
👉 Ye teen alag-alag cheezein hain:
MongoDB → The actual Database Management System (DBMS). Ye aapke computer/server me run hota hai.
MongoDB Compass → A GUI tool (software) to manage MongoDB easily. Ye ek tarah ka “front-end” hai jo aapke MongoDB ke data ko visual form me show karta hai.
MongoDB Atlas → A cloud service by MongoDB. Ye aapko MongoDB ko cloud me use karne ka option deta hai (no installation required). Free tier bhi available hai.
👉 Easy Analogy:
MongoDB = Car engine 🚗 (actual working part)
Compass = Dashboard screen 📟 (to easily control and view things)
Atlas = Ola/Uber 🚕 (you don’t own the car, you just use it from the cloud).
🔔 Stay Connected
If you found this article helpful and want to receive more such beginner-friendly and industry-relevant Node JS notes, tutorials, and project ideas — 📩 Subscribe to our newsletter by entering your email below.
And if you're someone who wants to prepare for tech interviews while having a little fun and entertainment, 🎥 Don’t forget to subscribe to my YouTube channel – Knowledge Factory 22 – for regular content on tech concepts, career tips, and coding insights!
Stay curious. Keep building. 🚀

