Registry / database / meadow-connection-mongodb

meadow-connection-mongodb

JSON →
library1.0.3jsnpmunverified

A MongoDB connection plugin for the Meadow data access layer that integrates with the Fable dependency injection framework, providing connection pooling, automatic collection creation and index management, and authentication support. Version 1.0.3, released under MIT license. It accepts both Meadow-style and native MongoDB configuration properties and supports auto-connect mode. Releases are infrequent and tied to the Retold framework ecosystem.

npm install meadow-connection-mongodb
INSTALL
IMPORT
SIG · MEADOW-CONNECTION-
M
meadow-connection-mongodb
databasejavascriptv1.0.3
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.

default
const libMeadowConnectionMongoDB = require('meadow-connection-mongodb');
import libMeadowConnectionMongoDB from 'meadow-connection-mongodb';
Package is CommonJS-only; no default ES module export.
libMeadowConnectionMongoDB
const libMeadowConnectionMongoDB = require('meadow-connection-mongodb');
import { MecadoMongoDB } from 'meadow-connection-mongodb';
Exports a single class constructor; named imports are not available.
Fable Service Integration
_Fable.serviceManager.addAndInstantiateServiceType('MeadowMongoDBProvider', libMeadowConnectionMongoDB);
_Fable.services.MeadowMongoDBProvider = new libMeadowConnectionMongoDB(_Fable);
Must use Fable's serviceManager to instantiate; direct constructor call requires passing Fable instance.

Shows how to instantiate Fable, add the MongoDB service, and connect asynchronously.

const libFable = require('fable'); const libMeadowConnectionMongoDB = require('meadow-connection-mongodb'); let _Fable = new libFable({ "MongoDB": { "Server": "localhost", "Port": 27017, "Database": "myapp" } }); _Fable.serviceManager.addAndInstantiateServiceType('MeadowMongoDBProvider', libMeadowConnectionMongoDB); _Fable.MeadowMongoDBProvider.connectAsync((pError, pDatabase) => { if (pError) { return console.error(pError); } let tmpDB = _Fable.MeadowMongoDBProvider.pool; console.log('Connected to database:', tmpDB.databaseName); });
Debug
Known issues
gotchaSettings must be under 'MongoDB' key in Fable config, not top-level.
fix
Place your MongoDB configuration inside the 'MongoDB' property of the Fable settings object.
affects: >=1.0
gotchaconnectAsync uses callback style, not Promise or async/await.
fix
Use callback pattern or promisify with util.promisify() for async/await.
affects: >=1.0
gotchaThe package is CommonJS and cannot be imported via ES modules in Node.js without a bundler or experimental flag.
fix
Use require() instead of import. If using TypeScript, set 'esModuleInterop': false.
affects: >=1.0
gotchaMongoClient instance is created on connect(); connection is not cached across multiple connect() calls.
fix
Do not call connect() multiple times; call disconnect() if reconnecting is needed.
affects: >=1.0
deprecatedThe property 'pool' returns a Db instance, not a connection pool object.
fix
Use 'pool' directly for database operations; it is the MongoDB Db object.
affects: >=1.0
gotchaIndexes for ID, GUID, and ForeignKey are automatically created; manual index creation may conflict.
fix
Rely on createTable() to handle indexes; avoid creating indexes manually on those fields.
affects: >=1.0
Errors
Common errors & fixes
TypeError: _Fable.MeadowMongoDBProvider.pool is undefined
connectAsync was not called before accessing pool.
fix
Ensure connectAsync callback is invoked before using pool getter.
Error: MongoError: Authentication failed
Incorrect username or password, or missing authentication database.
fix
Check the User and Password settings in the MongoDB config; add an 'authSource' property if needed.
TypeError: libMeadowConnectionMongoDB is not a constructor
Using ES import instead of require(), or package not found.
fix
Use 'const libMeadowConnectionMongoDB = require('meadow-connection-mongodb');'.
Error: Cannot find module 'meadow-connection-mongodb'
Package not installed or typo in module name.
fix
Run 'npm install meadow-connection-mongodb' and ensure the require path is correct.
TypeError: _Fable.serviceManager.addAndInstantiateServiceType is not a function
Fable library not properly initialized or incorrect version.
fix
Ensure Fable is installed (npm install fable) and instantiated as shown in quickstart.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
mongodbrequiredMongoDB Node.js driver for database connectivity
Agent activity
2 hits · last 30 days
node
2
Resources