v0.6.0-rc.1
HomeDocumentationWorking with data

Let your data do the math.

Build MongoDB 4.0 aggregation pipelines for summaries, grouping and transformations.

A first pipeline

javascript
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

StageUse
$matchFilter input documents
$projectChoose or calculate output fields
$groupGroup and aggregate values
$sort / $limitOrder and bound results
$unwindProcess elements of an array
$lookupJoin 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

javascript
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.

Standalone profile

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