Registry / database / mongodb-mql-engines

mongodb-mql-engines

JSON →
library0.0.4jsnpmunverified

Exposes, on demand, engines used by the MongoDB IntelliJ Plugin for index suggestions. This package provides programmatic access to the same query analysis and index suggestion engine used in the MongoDB IntelliJ IDE plugin. It analyzes MongoDB query patterns against sample documents and suggests optimal indexes to cover queries. Current version is 0.0.4. Release cadence is low. Key differentiator: it is the same engine used in the official MongoDB IntelliJ Plugin, so suggestions are production-tested. Alternatives require manual index design or third-party profilers.

npm install mongodb-mql-engines
INSTALL
IMPORT
SIG · MONGODB-MQL-ENGINE
M
mongodb-mql-engines
databasejavascriptv0.0.4
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.

analyzeNamespace
const { analyzeNamespace } = require('mongodb-mql-engines')
Package is CommonJS-only; no ESM exports. Use destructured require.
parseQuery
const { parseQuery } = require('mongodb-mql-engines')
Require the package and destructure the function.
suggestIndex
const { suggestIndex } = require('mongodb-mql-engines'); const index = await suggestIndex(queries)
suggestIndex returns a Promise. Always use await or .then().
Namespace
type Namespace = { database: string; collection: string }; // Not exported as a class
Namespace is a plain object returned by analyzeNamespace, not a class.

Demonstrates the full pipeline: analyzeNamespace, parseQuery, and suggestIndex.

const mql = require('mongodb-mql-engines'); const sampleDocuments = [ { a: 1, b: 2 }, { a: 5, b: true } ]; const ns = mql.analyzeNamespace( { database: 'mydb', collection: 'mycoll' }, sampleDocuments ); const query = mql.parseQuery({ a: 1, b: 2 }, ns); mql.suggestIndex([query]).then(index => { console.log(index); });
Debug
Known issues
breakingAPI is unstable and may change at any patch version (semver not followed)
fix
Pin to exact version (e.g., 'mongodb-mql-engines@0.0.4') and test upgrades.
affects: 0.x
breakingsuggestIndex returns a Promise; forgetting to await causes silent errors
fix
Always await suggestIndex or chain .then().
affects: >=0.0.1
gotchaanalyzeNamespace mutates the sampleDocuments array? Check documentation.
fix
Pass a shallow copy if original must remain unmodified.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'database')
analyzeNamespace called without namespace object or with missing fields.
fix
Ensure first argument is an object with 'database' and 'collection' string properties.
TypeError: mql.suggestIndex is not a function
Using default import (import mql from '...') in ESM context, but package is CJS only.
fix
Use const mql = require('mongodb-mql-engines') or wrap with createRequire for ESM.
UnhandledPromiseRejectionWarning: TypeError: queries.map is not a function
Passing a single query object instead of an array to suggestIndex.
fix
Wrap single query in an array: suggestIndex([myQuery]).
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
bsonrequiredUsed internally for EJSON parsing and document handling.
Agent activity
9 hits · last 30 days
node
8
Resources
mongodb-mql-engines — npm install mongodb-mql-engines · libregistry