Registry / database / mingo
library7.2.1jsnpmunverified

MongoDB query language for in-memory JavaScript objects. v7.2.1 (stable, actively maintained). Supports query, projection, aggregation pipeline (including accumulators, expressions, window operators, variables like $$ROOT), and update operations. Key differentiator: brings MongoDB Query Language (MQL) to client-side or server-side JS without a database, with lazy data processing, custom equality, and TypeScript types. Updated frequently with MongoDB operator parity.

npm install mingo
INSTALL
IMPORT
SIG · MINGO
M
mingo
databasejavascriptv7.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mingo (default import)
import * as mingo from 'mingo'
import mingo from 'mingo'
The default module is a namespace, not a default export. Use wildcard import.
find
import { find } from 'mingo'
const { find } = require('mingo')
CommonJS require is supported but ESM is preferred. Note that find returns a Cursor, not an array. Use .all() or .toArray().
Query
import { Query } from 'mingo'
import Query from 'mingo'
Query is a named export from the default module, not a default export. CommonJS: const { Query } = require('mingo').
Aggregator
import { Aggregator } from 'mingo'
import { Aggregator } from 'mingo/aggregator'
Aggregator is re-exported from the default module, but can also be imported from 'mingo/aggregator' for tree-shaking.
$match operator
import { $match } from 'mingo/operators/pipeline'
import { $match } from 'mingo'
Operators are not in the default module. Import from 'mingo/operators/pipeline' for pipeline stages, 'mingo/operators/query' for query operators. Context must be configured.

Shows query with find() and aggregation with custom context. Demonstrates both top-level functions and tree-shakeable operator registration.

import * as mingo from 'mingo'; const data = [ { name: 'Alice', age: 30, salary: 50000 }, { name: 'Bob', age: 21, salary: 30000 }, { name: 'Charlie', age: 25, salary: 40000 }, ]; // Query: find people aged 25 or older, project only name and age const result = mingo.find(data, { age: { $gte: 25 } }, { name: 1, age: 1 }).all(); console.log(result); // [ // { name: 'Alice', age: 30 }, // { name: 'Charlie', age: 25 } // ] // Aggregation: group by age and count import { Context } from 'mingo/core'; import { Aggregator } from 'mingo/aggregator'; import { $group, $sort } from 'mingo/operators/pipeline'; import { $sum } from 'mingo/operators/accumulator'; const ctx = new Context(); ctx.addOperators([$group, $sort, $sum]); const agg = new Aggregator([ { $group: { _id: '$age', count: { $sum: 1 } } }, { $sort: { count: -1 } } ], { context: ctx }); const aggResult = agg.run(data); console.log(aggResult); // [ // { _id: 30, count: 1 }, // { _id: 25, count: 1 }, // { _id: 21, count: 1 } // ]
Debug
Known issues
breakingIn v7, the default import changed from a default export to a namespace. Using `import mingo from 'mingo'` will fail or return undefined.
fix
Use `import * as mingo from 'mingo'` or import named exports individually.
affects: >=7.0.0
breakingIn v7, the `find` function no longer returns an array directly; it returns a `Cursor` object. Calling `.all()` or `.toArray()` is required to get results.
fix
Use `find(collection, query).all()` or pass options with `cursor: false` if available. Check docs for exact syntax.
affects: >=7.0.0
deprecatedThe `mingo/init` module and `use()` function for operator registration is deprecated in v7. Use `Context.addOperators()` instead.
fix
Import `Context` from 'mingo/core' and call `ctx.addOperators([...])`. Then pass `{ context: ctx }` to Aggregator or Query constructor.
affects: >=7.0.0
gotchaOperators are not automatically available when using the default module. Attempting to use an operator without registering it will throw an error like `Unknown operator: $project`.
fix
Either import from 'mingo' (which bundles all operators) or register only needed operators via `Context` for tree-shaking. The default module `mingo` already includes all operators, so you don't need to register if you use that.
affects: >=7.0.0
gotchaWhen using tree-shaking, the `$project` operator is a pipeline stage, but `$project` as a query operator exists in 'mingo/operators/query'. Be careful to import the correct one.
fix
Import pipeline stages from 'mingo/operators/pipeline' and query operators from 'mingo/operators/query'. For update operators, use 'mingo/operators/update'.
affects: >=7.0.0
Errors
Common errors & fixes
TypeError: mingo.find is not a function
Using default import `import mingo from 'mingo'` which is undefined in v7+.
fix
Use `import * as mingo from 'mingo'` or `import { find } from 'mingo'`.
Error: Unknown operator: $project
Attempting to use an operator without registering it in a custom Context, or using a non-default entry point without importing all operators.
fix
If you want all operators, use `import * as mingo from 'mingo'`. If tree-shaking, add the operator via `context.addOperators([$project])` and pass context to the Aggregator/Query constructor.
TypeError: result.all is not a function
Calling `.all()` on an array from an older version or accidentally calling `find` without the new Cursor API.
fix
Ensure you are using mingo v7+ and that `find` returns a Cursor. Alternatively, use `find(..., ..., { cursor: false })` if that option exists (check docs).
Upgrade
Version history
7.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Resources
packagemingo
mingo — npm install mingo · libregistry