Registry / database / mongodb-explain-compat

mongodb-explain-compat

JSON →
library3.3.33jsnpmunverified

Converts MongoDB SBE (Slot-Based Execution) explain output to the format used by MongoDB 4.4 explain, enabling compatibility for tools and applications that expect the older format. Current stable version is 3.3.33, released as part of the MongoDB Compass ecosystem. This package provides a best-effort conversion that is close enough for practical use, but not an exact match. It is a lightweight, focused utility for MongoDB developers and tools that need to interpret SBE explain plans.

npm install mongodb-explain-compat
INSTALL
IMPORT
SIG · MONGODB-EXPLAIN-CO
M
mongodb-explain-compat
databasejavascriptv3.3.33
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.

convertExplainCompat
import { convertExplainCompat } from 'mongodb-explain-compat'
const convertExplainCompat = require('mongodb-explain-compat')
Package is ESM-only; no default export.
convertExplainCompat (default)
import { convertExplainCompat } from 'mongodb-explain-compat'
import convertExplainCompat from 'mongodb-explain-compat'
No default export; use named import.
types
import type { ExplainCompatOptions } from 'mongodb-explain-compat'
TypeScript types are shipped; available for named export types.

Shows how to import and use convertExplainCompat to transform an SBE explain object to a 4.4-compatible format.

import { convertExplainCompat } from 'mongodb-explain-compat'; const sbeExplain = { queryPlanner: { winningPlan: { stage: 'COLLSCAN' } }, executionStats: { nReturned: 100 }, }; const compatExplain = convertExplainCompat(sbeExplain); console.log(compatExplain); // Output will be in MongoDB 4.4 explain format
Debug
Known issues
breakingThe output is an approximation and may not match MongoDB 4.4 explain output exactly. Critical differences may exist in some explain fields.
fix
Always validate that the converted output meets your requirements; do not rely on exact field parity.
affects: >=0.0.0
gotchaThe package is ESM-only; CommonJS require() will fail.
fix
Use import syntax or dynamic import(). Ensure your project is configured for ESM.
affects: >=3.0.0
deprecatedThe package is maintained as part of MongoDB Compass, but may not receive updates for new MongoDB versions immediately.
fix
Monitor the GitHub repository for updates or contribute improvements if needed.
affects: >=3.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Trying to use ESM import in a CommonJS project.
fix
Add "type": "module" to package.json or use dynamic import().
Module not found: Can't resolve 'mongodb-explain-compat' in '...'
Package is not installed or import path is incorrect.
fix
Run npm install mongodb-explain-compat and ensure the import matches the package name.
TypeError: convertExplainCompat is not a function
Using default import when only named export exists.
fix
Use import { convertExplainCompat } from 'mongodb-explain-compat'
Upgrade
Version history
3.3.33latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
mongodb-explain-compat — npm install mongodb-explain-compat · libregistry