MongoDB: Complete Course
Master MongoDB from core CRUD operations to advanced aggregation, indexing, and production deployment patterns. By the end, you build a fully functional Node.js REST API backed by a real MongoDB database.
Course Content
6 modules · 30 lessonsMongoDB Foundations
Set up MongoDB, understand its document model, and run your first queries in the shell.
What is MongoDB and when should you use it
NoSQL vs relational databases, document model, BSON format, collections vs tables, use cases, horizontal scaling
How to install MongoDB and connect with mongosh
MongoDB Community Server installation, mongosh CLI, connection string URI, show dbs command, use command, Atlas free tier
How MongoDB BSON and ObjectId work under the hood
BSON data types, ObjectId structure, timestamp encoding, _id field, supported types vs JSON, binary serialization
MongoDB schema design: embedding vs referencing documents
embedded documents, document references, one-to-many patterns, data duplication trade-offs, 16 MB document limit, denormalization
MongoDB vs PostgreSQL: which database should you pick
ACID transactions, schema flexibility, query language comparison, joins vs embedding, scaling strategies, hybrid use cases
CRUD Operations
Insert, query, update, and delete documents using MongoDB's full operator set.
How to insert documents into MongoDB collections
insertOne, insertMany, ordered vs unordered inserts, auto-generated _id, insert error handling, bulk write basics
How to query MongoDB documents with find and filters
find, findOne, equality filters, comparison operators, logical operators, projection, cursor methods, limit and skip
How to update documents in MongoDB with updateOne and updateMany
updateOne, updateMany, $set operator, $unset, $inc, $push, $pull, upsert option, replaceOne difference
How to delete documents in MongoDB safely
deleteOne, deleteMany, drop vs deleteMany, soft delete pattern, findOneAndDelete, write concern basics
MongoDB query operators complete reference: $in, $exists, $regex and more
$in, $nin, $exists, $type, $regex, $elemMatch, $size, array query operators, dot notation queries, nested document queries
Indexing and Query Performance
Create and manage indexes to make MongoDB queries fast at any data scale.
How MongoDB indexes work and why queries slow down without them
collection scan vs index scan, B-tree index structure, index entry, query explain plan, COLLSCAN vs IXSCAN, nReturned vs totalDocsExamined
How to create single field and compound indexes in MongoDB
createIndex, compound index, index direction, ESR rule, index on nested fields, sparse index, background index builds
MongoDB text indexes and full-text search explained
text index creation, $text operator, $search, score metadata, text index limitations, language support, Atlas Search vs text index
How to use explain() to diagnose slow MongoDB queries
explain verbosity levels, winning plan vs rejected plans, executionStats fields, SORT stage warning, index hint, slow query log
MongoDB TTL indexes: auto-expiring documents explained
TTL index creation, expireAfterSeconds, background cleanup thread, TTL index limitations, session storage use case, partial filter indexes
Aggregation Pipeline
Transform and analyze data using MongoDB's powerful aggregation pipeline framework.
How the MongoDB aggregation pipeline works
pipeline concept, stage execution order, $match, $group, $project, $sort, $limit, document transformation vs query
MongoDB $group and $project stages explained with examples
$group accumulator operators, $sum, $avg, $min, $max, $first, $last, $push, $addToSet, $project field inclusion and exclusion, computed fields
How to join collections in MongoDB with $lookup
$lookup pipeline join, from, localField, foreignField, as, $unwind, multiple lookups, pipeline-form $lookup, performance considerations
MongoDB $unwind, $addFields, and $bucket stages explained
$unwind array deconstruction, preserveNullAndEmpty, $addFields vs $project, $bucket for histograms, $bucketAuto, $facet for multi-dimensional aggregation
How to write MongoDB aggregation pipelines for real analytics
$facet multi-pipeline, $out and $merge to persist results, allowDiskUse for large datasets, aggregation pipeline optimization, pipeline explain
Mongoose and Node.js Integration
Build robust Node.js applications using Mongoose schemas, validation, middleware, and relationships.
How to set up Mongoose and define schemas in Node.js
Mongoose installation, Schema definition, SchemaTypes, model creation, connecting to MongoDB, connection events, disconnect handling
Mongoose validation: built-in and custom validators
required, min, max, minLength, maxLength, enum, match regex, custom validator function, ValidationError, async validators
Mongoose middleware (pre and post hooks) explained
document middleware, query middleware, pre save hook, post save hook, pre find hook, this context, next() function, error handling in hooks
Mongoose populate: how to handle document references
populate method, ObjectId ref, virtual populate, nested populate, select in populate, lean query optimization, N+1 problem awareness
Mongoose virtuals, statics, and instance methods
virtual properties, get and set virtuals, virtual populate, schema statics, instance methods, toJSON virtuals, schema options
Production MongoDB: Transactions, Replication, and Security
Deploy MongoDB safely with multi-document transactions, replica sets, security hardening, and connection pooling.
How MongoDB multi-document transactions work
ACID transactions, startSession, withTransaction, commitTransaction, abortTransaction, transaction limitations, performance cost, when to use vs when to avoid
How MongoDB replica sets work and why you need them
replica set architecture, primary and secondary nodes, automatic failover, read preferences, write concern, oplog, replication lag, arbiters
MongoDB security: authentication, authorization, and TLS setup
authentication mechanisms, SCRAM, createUser, role-based access control, built-in roles, custom roles, TLS/SSL configuration, IP whitelist, keyfile auth between nodes
MongoDB connection pooling and performance tuning in Node.js
connection pool, maxPoolSize, minPoolSize, MongoClient singleton pattern, serverSelectionTimeoutMS, socketTimeoutMS, connection string options, pool monitoring
How to back up and restore MongoDB databases in production
mongodump, mongorestore, mongodump options, Atlas backup, point-in-time recovery, oplog-based backup, backup strategies, backup testing
