Let your data do the math.
Build MongoDB 4.0 aggregation pipelines for summaries, grouping and transformations.
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 4.0.28. 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.
Documentation for BsonLite 0.6.0-rc.1. View SDK source · Download the validated SDK