CRUD Operations in MongoDB Compass sample programs for exercise
CRUD Operations in MongoDB Compass sample programs for exercise
v=KYIOJrE3zjk
MongoDB Compass is a GUI tool that allows you to interact with MongoDB without using the
command-line shell. You can create, read, update, and delete (CRUD) documents visually.
I. Connect to MongoDB
mongodb://localhost:27017
"name": "John",
"age": 25,
In the Filter box, enter a query (e.g., find users older than 25):
{ "age": { "$gt": 25 } }
1. Find a document, click the Edit (pencil) icon, and modify fields.
2. Click "Update".
{ "name": "John" }
{ "$set": { "age": 26 } }
……………………………………………………………………………………………………………………………………………….
{
"name": "Emma Smith",
"age": 28,
"department": "IT",
"salary": 75000,
"joining_date": "2023-05-10"
"age": 35,
"department": "IT",
"salary": 95000,
"joining_date": "2018-09-15"
},
"age": 30,
"salary": 70000,
"joining_date": "2020-02-20"
{ "department": "IT" }
2. In Filter, enter:
{ "department": "IT" }
2. In Filter, enter
2. In Filter, enter
"age": 21,
"gpa": 3.8,
"enrollment_year": 2022,
"age": 22,
"major": "Biology",
"gpa": 3.6,
"enrollment_year": 2021,
},
"age": 23,
"major": "Mathematics",
"gpa": 3.9,
"enrollment_year": 2020,
]
II. Read (Retrieve Student Data)
Reference:
https://www.mongodb.com/docs/manual/tutorial/update-documents/