Aggregation
Group, filter and summarize BsonLite documents with supported aggregation pipelines.
A first pipeline
const orders = BsonLite.collection('orders');
const totals = await orders.aggregate([
{ $match: { status: 'paid' } },
{ $group: {
_id: '$category',
revenue: { $sum: '$amount' },
orders: { $sum: 1 }
} },
{ $sort: { revenue: -1 } }
]).toArray();aggregate returns a cursor. A pipeline processes documents through ordered stages. Filter early with $match when appropriate, and build indexes to support the initial query.
Common building blocks
| Stage | Use |
|---|---|
| $match | Filter input documents |
| $project | Choose or calculate output fields |
| $group | Group and aggregate values |
| $sort / $limit | Order and bound results |
| $unwind | Process elements of an array |
| $lookup | Join supported local collections |
Use the stages and expressions available in MongoDB 9.0.4. New server features do not become available by updating only the Node.js driver.
Disk use and encryption
const summary = await orders.aggregate([
{ $sort: { createdAt: -1 } },
{ $group: { _id: '$customerId', total: { $sum: '$amount' } } }
], { allowDiskUse: true }).toArray();The full native Windows engine patches temporary-file encryption hooks. Real aggregation spill-file encryption is part of its native test suite. This does not turn the engine into an unlimited-memory system; allowDiskUse, workload size and disk capacity still matter.
Replica-set transactions and change streams are not provided by this standalone deployment. Server-side JavaScript is disabled.
BsonLite 0.7.0-alpha.0 · BsonLite Console 0.3.0 · BsonLite source · Downloads