What MongoDB Does
- Document model — flexible schema, nested objects, arrays
- CRUD API — insertOne, find, updateOne, deleteOne
- Aggregation pipeline — stages for filter/group/project/lookup
- Indexing — single, compound, text, geospatial, vector (Atlas)
- Replication — replica sets for HA
- Sharding — horizontal scale across shards
- Transactions — multi-document ACID (v4+)
- Change streams — subscribe to data changes
- GridFS — large file storage
- Time-series — optimized time-series collections
Architecture
Primary-secondary replica set for HA. Writes go to primary, replicated to secondaries via oplog. Sharded clusters split data by shard key across multiple replica sets. WiredTiger is the default storage engine since 3.2.
Self-Hosting
# Docker Compose replica set
version: "3"
services:
mongo:
image: mongo:7
command: --replSet rs0 --bind_ip_all
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db
volumes:
mongo-data:Since v5, MongoDB Community Edition uses SSPL. Read the license before SaaS-wrapping.
Key Features
- Document model (JSON-like)
- Flexible schema
- Aggregation pipeline
- Full-text search (Atlas Search)
- Vector search (Atlas, v7+)
- Time-series collections
- Change streams
- Multi-document transactions
- Geospatial queries
- Horizontal scaling (sharding)
Comparison
| Database | Model | Transactions | Scale |
|---|---|---|---|
| MongoDB | Document | Multi-doc ACID (v4+) | Sharding |
| PostgreSQL + JSONB | Relational + JSON | ACID | Vertical + logical repl |
| Couchbase | Document | ACID | Sharding |
| DynamoDB | Key-value + doc | ACID | Managed |
| Firestore | Document | ACID | Managed |
| Cassandra | Wide column | Eventual | Multi-master |
FAQ
Q: MongoDB vs PostgreSQL? A: Postgres + JSONB can do 80% of what MongoDB can (plus ACID and a mature SQL ecosystem). MongoDB's advantages are horizontal scaling, flexible schema, and a popular ORM (Mongoose).
Q: What does SSPL mean? A: Source Available, but restricts SaaS commercial use (if you turn MongoDB into a managed service, you must open-source the entire service stack). Personal use and embedding in applications are completely fine.
Q: Vector search? A: MongoDB Atlas has built-in vector search starting from v7 (RAG, semantic search). The local Community edition can also use it via the vector search index.
Sources
- Docs: https://www.mongodb.com/docs
- GitHub: https://github.com/mongodb/mongo
- License: SSPL