The Bookshelf API of Express.js keeps its books in a JavaScript array. Restart the process and they are gone; run two copies behind a load balancer and they disagree. Fixing that is MongoDB 1,815 's job, and it is the letter the acronym starts with.
MongoDB stores documents — ordered, typed, nested records that look like JSON objects — in collections instead of rows in tables. A book, its author reference, its tags and its three most recent reviews live in one document and come back in one read, with no join. That is the whole pitch, and it fits the data a web application deals with. It is also the source of every mistake beginners make: the freedom to nest reviews inside a book lets you nest ten thousand of them, past the 16 MB ceiling, where no index reaches.
The version here is MongoDB 8.3, the current stable release; 8.0 and 7.0 are the other supported versions. Everything from The Document Model and BSON on was executed against a local mongod 8.3.11 through mongosh 2.12.0 403 and the driver mongodb 7.6.0, and the transcripts are real. Where a feature needs a replica set, a paid Atlas 1,815 tier or a license the Community build lacks, the text says so rather than inventing output.
Two client libraries matter: the mongodb driver wraps the wire protocol thinly, and Mongoose 9.10.1 243,355 adds schemas, casting, validation and population on top of it. By the end of the chapter the Bookshelf API is backed by a real database with indexes that serve its queries, a schema designed around them, seed data, migrations and tests — a data layer Next.js reuses from Next.js 10,514 .
What you will learn
How to install, run and connect to MongoDB locally, in Docker 514 and on Atlas.
How BSON differs from JSON, and what ObjectId and GridFS do.
How to insert, read, update and delete documents, and write efficient filters.
How the aggregation pipeline groups, joins, buckets and windows data.
How indexes are stored and chosen, and how to find a slow query.
How to model one-to-many, many-to-many and unbounded relationships.
How transactions, change streams, TTL indexes and vector search work.
How to run a replica set, secure it, back it up and monitor it.
How to use the driver and Mongoose, and how to seed, migrate and test.
Sections
- Getting MongoDB Running
- The Document Model and BSON
- CRUD Operations
- Querying Documents
- The Aggregation Pipeline
- Indexes and Query Performance
- Schema Design
- Transactions and Streams
- Collections and Search
- Operating a MongoDB Deployment
- The Node.js Driver
- Mongoose
- Seeding and Testing
- Compared with Others
- Test Yourself!