Registry / database / flamongo

flamongo

JSON →
library2.0.5jsnpmunverified

A CLI tool and library for analyzing MongoDB query performance and recommending optimal indexes. Current stable version is 2.0.5. Release cadence is irregular. It works by generating test data, creating indexes (either user-specified or all possible combinations), running queries, and providing human-readable statistics. Differentiators: unlike general profiling tools, it explicitly tests multiple indexes and suggests the best one for each query.

npm install flamongo
INSTALL
IMPORT
SIG · FLAMONGO
F
flamongo
databasejavascriptv2.0.5
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.

flamongo
import flamongo from 'flamongo'
const flamongo = require('flamongo')
Package is ESM-only. Default export provides both CLI and programmatic API.
explain
import { explain } from 'flamongo'
Named export for programmatic usage. Available as a method on default import as well.
bestIndex
import { bestIndex } from 'flamongo'
Named export for programmatic usage. Available as a method on default import as well.

Demonstrates programmatic usage of the explain function to analyze query performance against specified indexes.

import flamongo from 'flamongo'; const input = { indexKeys: [{ 'name.first': 1 }, { birthday: 1 }], queries: [{ 'name.first': 'Richard' }, { 'name.first': 'John', vegan: false }], schema: { name: { first: 'first', last: 'last' }, vegan: 'bool', birthday: 'date' } }; flamongo.explain(input, { url: 'mongodb://localhost:27017/test' }) .then(results => console.log(JSON.stringify(results, null, 2))) .catch(err => console.error(err));
Debug
Known issues
breakingESM-only since v2: package no longer supports CommonJS require().
fix
Use import statement instead of require(). If using CommonJS, use dynamic import: const flamongo = await import('flamongo');
affects: >=2.0.0
deprecatedThe `best-index` command may be deprecated in future versions; consider using the programmatic API instead.
fix
Use flamongo.bestIndex() programmatically.
affects: >2.0.0
gotchaFlamongo requires a running MongoDB instance; it does not start or manage MongoDB itself.
fix
Ensure MongoDB is running and accessible at the default port 27017 or provide a custom URL.
affects: *
gotchaThe schema object must match the structure of your documents exactly; mismatched types can cause incorrect index recommendations.
fix
Verify that the schema field types correspond to actual data types used in MongoDB collections.
affects: *
gotchaGenerating all possible indexes (best-index) can be extremely slow for collections with many fields due to combinatorial explosion.
fix
Limit the number of fields in the schema or use the explain command with a curated set of indexes instead.
affects: *
Errors
Common errors & fixes
Cannot find module 'flamongo'
Package not installed globally or locally.
fix
Run `npm install -g flamongo` for global CLI, or `npm install flamongo` for local project use.
flamongo.explain is not a function
Attempting to use default import with require() in CommonJS context.
fix
Use `import flamongo from 'flamongo'` with ESM or `const flamongo = await import('flamongo')` for dynamic import.
Error: connect ECONNREFUSED 127.0.0.1:27017
MongoDB is not running on the default host and port.
fix
Start MongoDB server with `mongod` or provide a valid connection URL via options.
Upgrade
Version history
2.0.5latest on npm
Audit
Dependencies
mongodbrequiredRequired to connect to MongoDB and run queries against test collections.
Agent activity
6 hits · last 30 days
node
6
Resources