Level 1 · MongoDB Foundations¶
Level 1 gets you from "I've heard MongoDB stores JSON" to writing correct application code against it.
That takes more than learning find() and insertOne(). It means knowing what a document really is
(BSON, with types JSON doesn't have), why {price: 0.1} adds up wrong, why a filter on an array matched
a student who failed the test, why a read-then-write counter lost 80% of its increments, and why a
mongorestore "succeeded" without restoring anything.
Every lesson is built from commands run against a real server — MongoDB 9.0.2 — and every output shown is what that server returned, errors included.
Prerequisites: basic programming in Python or JavaScript, and comfort at a terminal. No database experience is required, though if you know SQL you'll see where the two models differ.
Modules¶
- How MongoDB Is Built: mongod, Storage & a Local Lab — install from the official tarball, start a throwaway server, and look inside its data directory, log and cache.
- mongosh Like a Pro — connection strings, cursors and batches,
scripts, JSON output modes, numbers, errors and
.mongoshrc.js. - Documents, BSON & Data Types — ObjectId anatomy, Decimal128 for money, real dates, null vs missing, mixed-type comparisons and the 16 MB limit.
- Inserting & Querying Documents — filters, comparison and logical
operators, projection, sort/skip/limit, counts and
$expr. - Querying Arrays & Embedded Documents — "contains" semantics,
$all,$size, why$elemMatchmatters, and trimming arrays in projections. - Update Operators, Upserts & Array Updates — atomic
$incvs lost updates,$pushwith$slice, positional and filtered updates, upserts,findOneAndUpdate. - Deletes, Replaces & Bulk Writes — safe deletes,
drop()vsdeleteMany({}), ordered vs unordered batches andbulkWrite. - Drivers: PyMongo & the Node.js Driver — one shared client, connection pools, type mapping, timeouts, errors and retryable writes.
- mongoimport, mongoexport, mongodump & mongorestore — typed CSV imports, Extended JSON, archives and namespace remapping.
- Project — Recipe Box Data Layer — a tested Python data layer with unique slugs, atomic ratings, array updates and keyset paging.
After Level 1¶
You can store and change data correctly. Level 2 is about doing it well: deciding what to embed and
what to reference, enforcing a schema in a "schemaless" database, and designing the indexes that turn
the collection scans you've been running into fast, targeted reads — with explain() to prove it.