MongoDB $bucket
Place numeric values into ranges with boundaries you choose.
Each boundary begins an inclusive range and the following boundary ends it. Use `output` accumulators to calculate a count, total, or other measure for each range.
Stages are the top-level steps in a pipeline. Each stage receives documents, changes the stream in one specific way, and passes its output to the next stage.
Course use: Exercise 09.
Example pipeline syntax
{ $bucket: {
groupBy: "$total",
boundaries: [0, 100, 200, 1000],
output: { count: { $sum: 1 } }
} }