In this video, we connect our Express server to MongoDB
using Mongoose.
We will set up MongoDB Atlas, get our connection string, save it in our .env file, and write the connectDB function.
By the end of this video — our server will be connected
to a real database.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📌 WHAT YOU WILL LEARN
What is MongoDB and how it stores data
What is Mongoose and why we use it
How to create a free MongoDB Atlas account
How to get the MongoDB connection string
What is MONGO_URI and how to save it in .env
How to write the connectDB function
How to use async await and try catch
How to call connectDB in index.js
How to confirm database is connected
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🗂️ COMPLETE SERIES PLAYLIST
• Learn MERN Stack by Building a Real Projec...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📌 ALL VIDEOS IN THIS SERIES
#1 - Project Intro + Demo
#2 - Backend Setup — Express + dotenv + cors
#3 - MongoDB Connection + Mongoose (This Video)
#4 - Task Model + Schema
#5 - CRUD Controllers
#6 - Routes + Postman Testing
#7 - Frontend Setup — Vite + React + Tailwind CSS
#8 - Fetch + Display Tasks
#9 - Add + Delete Tasks
#10 - Complete Task + Full Project Review
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🛠️ TOOLS USED
Node.js — nodejs.org
VS Code — code.visualstudio.com
MongoDB Atlas — mongodb.com/atlas
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📦 PACKAGES USED IN THIS VIDEO
mongoose
dotenv (already installed)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📁 FILES CREATED IN THIS VIDEO
server/
├── src/
│ ├── config/
│ │ └── db.js
│ └── index.js (updated)
└── .env (updated)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
If this helped you, please like and subscribe to jdcodebase. It really helps the channel grow.
#mern #mernstack #mongodb #mongoose #nodejs
#mongodbatlas #webdevelopment #beginners
#javascript #jdcodebase