Skip to main content
MongoDB

MongoDB

Here's how I got my head around MongoDB — not just how to call it, but what it's actually doing underneath. I'm just sharing the way I wish it had been explained to me. If you know JSON, you're already halfway there. By the end of this topic you'll be able to explain what happens on disk when you insert a document and create an index, and that's the kind of understanding that separates someone who uses a database from someone who understands one.

Learn this interactively in NotebookLM

I turned these notes into a NotebookLM notebook so you can ask MongoDB anything, get audio overviews, and explore at your own pace.

Notebook link coming soon.

The one-sentence version

MongoDB is a document database: instead of tables and rows, it stores documents that look like JSON objects, grouped into collections.

That's the whole mental model. Everything else is detail layered on top.

Where it actually shows up

This isn't academic — MongoDB runs real products at scale:

  • eBay, Forbes, Adobe use it for content and catalog data that changes shape often.
  • Real-time analytics & IoT pipelines lean on it because documents map naturally to events.
  • It's the "M" / default database in countless startups and the MEAN/MERN stack from the JavaScript ecosystem.

It shines when your data is document-shaped (read and written together as a unit) and your schema evolves quickly — exactly the situation a fast-moving app is usually in.

How I've broken this topic down

I kept each page short but deep. Read them in order:

#PageWhat you'll understand
1The Mental ModelDocuments, collections, _id, and why the model clicks fast if you know JavaScript
2How It Stores DataBSON on disk + the WiredTiger storage engine (cache, journaling, MVCC)
3IndexingWhy a query is fast or slow — the B-tree behind every index
4Querying & AggregationCRUD, the operator + update toolbox, and the aggregation pipeline
5Data ModelingThe big decision: embed vs. reference, and the patterns that follow
6ScalingReplica sets, sharding, and change streams — surviving failure and growing
7Transactions & ConsistencyAtomicity, multi-doc ACID transactions, read/write concern, causal consistency
8Operating MongoDBTime-series & capped collections, security, search, connection pooling

Let's start with the mental model. 👉 The Mental Model