The developer data platform. Learn flexible schemas, powerful aggregations, and scaling with documents.
Understanding the shift from Rows/Columns to Collections/Documents.
(Click to reveal)
The format MongoDB uses to store data.
Like JSON, but supports more types like `Date` and `NumberLong` for efficiency.
(Click to reveal)
Equivalent to SQL Tables, but schema-less by default.
You can store different document structures in the same collection.
(Click to reveal)
Distributing data across multiple servers (shards).
Allows MongoDB to handle massive datasets beyond the limit of a single machine.
(Click to reveal)
A group of mongo processes maintaining the same data set.
Provides automatic failover and data redundancy.
Data flows through stages like an assembly line. Click the stages to see how the documents transform.
status: "A"
_id: "$cust_id", total: { $sum: "$amount" }
total: -1
Click on the pipeline stages to see the data transformation logic.
Filters the document stream. Only documents matching the condition pass to the next stage.
{ $match: { status: "A" } }
// Input:
// { id: 1, status: "A", amount: 50 }
// { id: 2, status: "B", amount: 100 }
// Output:
// { id: 1, status: "A", amount: 50 }
Groups input documents by a specified identifier expression and applies accumulator expressions (like sum, avg).
{
$group: {
_id: "$cust_id",
total: { $sum: "$amount" }
}
}
// Result:
// { _id: "abc", total: 150 }
Reorders the document stream by a specified key. 1 for ascending, -1 for descending.
{ $sort: { total: -1 } }
// Orders customers with highest total first.
Documents in the same collection don't need the same fields. This allows you to evolve your data model without expensive `ALTER TABLE` operations.
Test your MongoDB proficiency.
1. What is the MongoDB equivalent of a SQL Table?
2. Which pipeline stage is used to filter documents?
3. What is "Sharding"?