🧩 Week 11 – MongoDB + Mongoose Integration
🎯 Goal: Learn NoSQL database (MongoDB), how to connect it to Express using Mongoose, and build a complete RESTful API.
📚 Daily Breakdown
—
✅ Day 1 – Introduction to MongoDB
🧠Topics:
- What is MongoDB? NoSQL vs SQL
- Installing MongoDB locally OR using MongoDB Atlas
- Understanding documents, collections, and databases
- MongoDB Compass GUI overview
🛠Activities:
- Create a sample database called blogDB
- Create a posts collection with 3 documents (title, content)
- Practice CRUD using MongoDB Compass
—
✅ Day 2 – Mongoose Basics
🧠Topics:
- What is Mongoose and why use it?
- Installing Mongoose via npm
- Defining Mongoose schemas and models
- Connecting Express to MongoDB using Mongoose
🛠Activities:
- Create a schema for a Post (title, content, date)
- Create and save a document using Mongoose
- Test data creation via Postman
—
✅ Day 3 – MongoDB CRUD via Express API
🧠Topics:
- Create RESTful endpoints using Mongoose models
- GET: Fetch all posts / Fetch one post
- POST: Add a new post
- PUT/PATCH: Update a post
- DELETE: Delete a post
🛠Activities:
- Build a Post API with complete CRUD
- Use Postman to test all routes
- Handle error responses (404, 500)
—
✅ Day 4 – Build Blog API (Backend)
🧠Tasks:
- Create blog schema: title, content, author, tags, date
- Build routes:
- GET /posts (all)
- GET /posts/\:id
- POST /posts
- PUT /posts/\:id
- DELETE /posts/\:id
🛠Bonus:
- Add validation with Mongoose
- Add slug field using title (e.g. post-title-here)
—
✅ Day 5 – Postman, JSON, and Advanced Mongoose
🧠Topics:
- Working with Postman collections
- Mongoose validation: required, minlength
- Timestamps, default fields, enum
- Populate, reference other collections
🛠Activities:
- Add timestamps to blog model
- Create Author model and reference in Post
- Use .populate() to get author details in post response
—
✅ Day 6–7 – Final Project: Blog Backend API
🧠Tasks:
- Setup full backend REST API using:
- Express
- MongoDB via Mongoose
- CRUD routes
- Models:
- Post
- Author/User
- Comments (optional)
🛠Bonus:
- Test with Postman collection
- Prepare for integration with React frontend (Week 14)
—
Would you like me to continue with 🧩 Week 12 – React Fundamentals next?