Let's think about this for a moment
In this mini project, you'll build a tasks collection in MongoDB, the kind you'd typically find in a task manager application. Since MongoDB is a document-based database, you can flexibly store fields like a task's title, status, priority, dueDate, and tags all within a single document. When starting a real project, the first thing to do is create the database and collection, then insert a bit of sample data to try it out. This step lays the foundation for Part 2 (query/update) and Part 3 (index/aggregation) that follow.
Let's build it hands-on
Open a new database called taskManagerDB in mongosh using the use command. Then insert three or four documents into the tasks collection with insertMany() — design them to include fields like title (string), status (pending/in-progress/completed), priority (low/medium/high), dueDate (Date), and tags (array). After inserting, use find().pretty() to look back at the data in the collection and check whether the schema structure is correct. Choose your field names and data types carefully so they'll be useful for Part 2 and Part 3.
Code Example
// database အသစ်ကို ဖွင့်ပါ (မရှိသေးရင် အလိုအလျောက် ဖန်တီးမည်)
use taskManagerDB
// tasks collection ထဲကို sample task များ insert လုပ်ပါ
db.tasks.insertMany([
{
title: "Design homepage",
status: "pending",
priority: "high",
dueDate: new Date("2026-09-01"),
tags: ["design", "urgent"]
},
{
title: "Write unit tests",
status: "pending",
priority: "medium",
dueDate: new Date("2026-09-05"),
tags: ["testing"]
},
{
title: "Fix login bug",
status: "in-progress",
priority: "high",
dueDate: new Date("2026-08-28"),
tags: ["bug", "urgent"]
}
])
// insert လုပ်ထားတဲ့ data တွေကို ပြန်ကြည့်ပါ
db.tasks.find().pretty()After running insertMany(), it returns acknowledged: true along with three insertedIds, and find() shows all three documents with their fields.5-minute try-it
Add one more task document, this time with an extra assignee field (string) — spend 5 minutes trying this out to see how each document in a collection doesn't need to share the same field structure.
A quick word of caution
MongoDB doesn't strictly enforce a schema, but it's still good practice to keep field name spelling and data types consistent across all your documents — otherwise your query results can end up wrong.