database Introduced in L3

MongoDB

The dominant document database. Schemaless flexibility, JSON-shaped documents, harder consistency tradeoffs.

Mindmap

hover · click to navigate
this tech depends on / used by alternative Shipyard anchor
What it is

The plain-English version

MongoDB is a document database — it stores JSON-like documents (BSON, technically) instead of rows in tables. You can have wildly different shapes in the same collection. Schemaless by default; schema validation is opt-in. Released 2009. The reference "NoSQL" database.

Why it exists

The problem it solves

MongoDB shines when your data doesn't fit a rectangle — nested structures, optional fields, rapidly evolving shape. It struggles when your data does fit a rectangle and benefits from joins. Many teams that started with Mongo for flexibility migrated to Postgres + JSON columns once schemas stabilized.

What it competes with

Alternatives

AlternativeTypeWhen it wins
PostgresdatabaseThe serious open-source relational database. The default choice for most production apps that need structured data.
Redisin-memory storeThe in-memory key-value store. Fast cache, fast queue, fast everything that doesn't need durability.
PrismaORMThe TypeScript-first ORM. Schema-driven, type-safe, the default for most modern Node apps.
Where it shows up in Shipyard

Deep links

Vocabulary

The words you'll hear

Document / Collection
A JSON-shaped record / a group of documents (analogous to row / table).
Aggregation pipeline
Mongo's query language. Stages of $match, $group, $lookup.
Index
Same idea as Postgres. Compound indexes are common.
Sharding
Splitting a collection across multiple servers. Mongo's strong scale-out story.
Replica set
Primary + replicas. Failover happens automatically.
Atlas
MongoDB's managed cloud service.
Prompting

Bad vs. good prompt for MongoDB

✕ Bad prompt
use mongodb for tasks
✓ Good prompt
Design a MongoDB schema for Tasklane tasks where each task can have nested comments. Use the embed-vs-reference rule of thumb (embed for bounded counts, reference for unbounded). Show the document shape, the indexes, and an aggregation that returns task with comment count. Use Mongoose with TypeScript schemas.

Why it works: Asks for the design pattern decision (embed vs reference) explicitly — this is the central Mongo design question. Specifies the ODM (Mongoose) and language.

Pitfalls

What bites real teams

⚠ Joins-by-aggregation are slow

$lookup is Mongo's join. It works but isn't as performant as a SQL join. Denormalize when you can.

⚠ Schemaless is a trap

"Just throw documents in!" — six months later, your collection has 47 fields, half deprecated. Use schema validation.

⚠ Transactions exist but cost

Mongo got multi-document transactions in 4.0, but they're more expensive than in Postgres. Design to need fewer.

References

Official docs only