Let's think about this for a second
This exercise isn't about learning anything new — it's about practicing the insert, find, update, and delete operations you covered in the Basic chapter, using the knowledge you already have. Every task will work on a single students collection. By working through the query filters, update operators, and delete methods yourself, you'll get much more comfortable with the syntax.
Exercises
Task 1: Create a new students collection and insert 4 student documents with name, age, grade, and isActive fields using insertMany(). Task 2: Use find() to look up only students whose age is over 18. Task 3: Use updateOne() to change one student's grade. Task 4: Use deleteMany() to delete all student documents where isActive: false.
Code Example
// Task 1: sample data insert လုပ်ပါ
db.students.insertMany([
{ name: "Aye Aye", age: 19, grade: "A", isActive: true },
{ name: "Ko Ko", age: 17, grade: "B", isActive: true },
{ name: "Su Su", age: 21, grade: "C", isActive: false },
{ name: "Min Min", age: 16, grade: "B", isActive: false }
])
// Task 2: age > 18 student များကို ရှာပါ (ဒီနေရာမှာ query ရေးပါ)
// Task 3: student တစ်ဦးရဲ့ grade ကို updateOne() ဖြင့် ပြောင်းပါ (ဒီနေရာမှာ update ရေးပါ)
// Task 4: isActive: false ဖြစ်သော student များကို deleteMany() ဖြင့် ဖျက်ပါ (ဒီနေရာမှာ delete ရေးပါ)After Task 4, only student documents with isActive: true should remain in the collection.5-Minute Try-It
Rewrite Task 2's query using the $gte operator so it includes age 18 as well — take 5 minutes and see how the results differ.
A quick word of caution
Before running deleteMany(), first run a find() with the same filter condition to confirm exactly how many documents will be affected.