Registry / database / cascade-config-mongodb

cascade-config-mongodb

JSON →
library1.2.1jsnpmunverified

MongoDB extension for cascade-config that adds a `.mongodb()` loader to read configuration objects from MongoDB collections using variable substitution in URL, db, collection, and _id fields. Current stable version is 1.2.1. Release cadence is low, primarily maintenance updates. Key differentiator: seamlessly integrates with cascade-config's hierarchical config system and supports environment variable expansion in all connection parameters. Deprecated in favor of newer versions requiring cascade-config >=1.9.0 (since v1.2.0). Only works with MongoDB driver v3 connection strings.

npm install cascade-config-mongodb
INSTALL
IMPORT
SIG · CASCADE-CONFIG-MON
C
cascade-config-mongodb
databasejavascriptv1.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.

cascade-config-mongodb
var CC_mongodb = require('cascade-config-mongodb');
import CC_mongodb from 'cascade-config-mongodb';
This package is CJS-only; ESM import will fail. Use require() or dynamic import() with default.
cascade-config
var CC_base = require('cascade-config');
const { cascadeConfig: CC_base } = require('cascade-config');
cascade-config exports a constructor function directly; no named exports.
CC (augmented)
var CC = CC_mongodb(CC_base); var config = new CC();
var config = new CC_mongodb(CC_base)();
CC_mongodb is a higher-order function that takes the base CC constructor and returns an augmented constructor. Instantiate with new on the returned function.

Demonstrates how to augment cascade-config with the MongoDB loader, create a config hierarchy with an inline object and MongoDB source, then execute .done() to retrieve the merged config.

var CC_base = require('cascade-config'); var CC_mongodb = require('cascade-config-mongodb'); var CC = CC_mongodb(CC_base); var config = new CC(); config .obj({ cc: { n: 'ooo' }, x: 0 }) .mongodb({ url: 'mongodb://localhost:27017', db: 'myconfig', coll: 'config', id: 'app-settings' }) .done(function (err, cfg) { if (err) console.error(err); else console.log(cfg); });
Debug
Known issues
deprecatedStarting with v1.2.0, this package only works with cascade-config versions >= 1.9.0.
fix
Update cascade-config to 1.9.0 or later, or stick with an older version of this package.
affects: >=1.2.0
gotchaThe .mongodb() method modifies the config prototype globally; using different versions in the same process may conflict.
fix
Ensure only one version of cascade-config and cascade-config-mongodb is installed. Use npm dedupe if necessary.
affects: all
gotchaThe _id field is deleted from the returned configuration object. If you need the original _id, store it separately before calling .mongodb().
fix
Clone the document or read _id manually before passing to cascade-config.
affects: all
Errors
Common errors & fixes
TypeError: CC_mongodb is not a function
Using ESM import instead of require, or the module was not installed correctly.
fix
Use const CC_mongodb = require('cascade-config-mongodb'); and ensure the package is in node_modules.
Error: mongodb is not defined
The mongodb driver package is missing or incompatible version.
fix
Install mongodb driver v3: npm install mongodb@3
MongoError: failed to connect to server
Invalid URL, network issue, or MongoDB not running.
fix
Check mongodb URL and ensure MongoDB is accessible. Use a valid connection string like 'mongodb://localhost:27017'.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
mongodbrequiredrequired mongodb driver v3 for database operations
cascade-configrequiredpeer dependency: the extension modifies cascade-config's prototype
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
cascade-config-mongodb — npm install cascade-config-mongodb · libregistry