{"id":43041,"library":"meadow-connection-mongodb","title":"Meadow Connection MongoDB","description":"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.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/stevenvelozo/meadow-connection-mongodb","tags":["javascript","meadow","mongodb","database"],"install":[{"cmd":"npm install meadow-connection-mongodb","lang":"bash","label":"npm"},{"cmd":"yarn add meadow-connection-mongodb","lang":"bash","label":"yarn"},{"cmd":"pnpm add meadow-connection-mongodb","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"MongoDB Node.js driver for database connectivity","package":"mongodb","optional":false}],"imports":[{"note":"Package is CommonJS-only; no default ES module export.","wrong":"import libMeadowConnectionMongoDB from 'meadow-connection-mongodb';","symbol":"default","correct":"const libMeadowConnectionMongoDB = require('meadow-connection-mongodb');"},{"note":"Exports a single class constructor; named imports are not available.","wrong":"import { MecadoMongoDB } from 'meadow-connection-mongodb';","symbol":"libMeadowConnectionMongoDB","correct":"const libMeadowConnectionMongoDB = require('meadow-connection-mongodb');"},{"note":"Must use Fable's serviceManager to instantiate; direct constructor call requires passing Fable instance.","wrong":"_Fable.services.MeadowMongoDBProvider = new libMeadowConnectionMongoDB(_Fable);","symbol":"Fable Service Integration","correct":"_Fable.serviceManager.addAndInstantiateServiceType('MeadowMongoDBProvider', libMeadowConnectionMongoDB);"}],"quickstart":{"code":"const libFable = require('fable');\nconst libMeadowConnectionMongoDB = require('meadow-connection-mongodb');\n\nlet _Fable = new libFable({\n  \"MongoDB\": {\n    \"Server\": \"localhost\",\n    \"Port\": 27017,\n    \"Database\": \"myapp\"\n  }\n});\n\n_Fable.serviceManager.addAndInstantiateServiceType('MeadowMongoDBProvider', libMeadowConnectionMongoDB);\n\n_Fable.MeadowMongoDBProvider.connectAsync((pError, pDatabase) => {\n  if (pError) { return console.error(pError); }\n  let tmpDB = _Fable.MeadowMongoDBProvider.pool;\n  console.log('Connected to database:', tmpDB.databaseName);\n});","lang":"javascript","description":"Shows how to instantiate Fable, add the MongoDB service, and connect asynchronously."},"warnings":[{"fix":"Place your MongoDB configuration inside the 'MongoDB' property of the Fable settings object.","message":"Settings must be under 'MongoDB' key in Fable config, not top-level.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use callback pattern or promisify with util.promisify() for async/await.","message":"connectAsync uses callback style, not Promise or async/await.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use require() instead of import. If using TypeScript, set 'esModuleInterop': false.","message":"The package is CommonJS and cannot be imported via ES modules in Node.js without a bundler or experimental flag.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Do not call connect() multiple times; call disconnect() if reconnecting is needed.","message":"MongoClient instance is created on connect(); connection is not cached across multiple connect() calls.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use 'pool' directly for database operations; it is the MongoDB Db object.","message":"The property 'pool' returns a Db instance, not a connection pool object.","severity":"deprecated","affected_versions":">=1.0"},{"fix":"Rely on createTable() to handle indexes; avoid creating indexes manually on those fields.","message":"Indexes for ID, GUID, and ForeignKey are automatically created; manual index creation may conflict.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'1.0.3':35 'accept':41 'access':12 'authent':32 'auto':54 'auto-connect':53 'automat':25 'collect':26 'configur':49 'connect':2,6,23,55 'creation':27 'data':11 'databas':70 'depend':19 'ecosystem':66 'fabl':18 'framework':21,65 'index':29 'infrequ':59 'inject':20 'integr':15 'javascript':67 'layer':13 'licens':39 'manag':30 'meadow':1,10,44,68 'meadow-styl':43 'mit':38 'mode':56 'mongodb':3,5,48,69 'nativ':47 'plugin':7 'pool':24 'properti':50 'provid':22 'releas':36,57 'retold':64 'style':45 'support':33,52 'tie':61 'version':34","created_at":"2026-06-05T16:57:53.831371+00:00","updated_at":"2026-06-05T16:57:53.831371+00:00","problems":[{"fix":"Ensure connectAsync callback is invoked before using pool getter.","cause":"connectAsync was not called before accessing pool.","error":"TypeError: _Fable.MeadowMongoDBProvider.pool is undefined"},{"fix":"Check the User and Password settings in the MongoDB config; add an 'authSource' property if needed.","cause":"Incorrect username or password, or missing authentication database.","error":"Error: MongoError: Authentication failed"},{"fix":"Use 'const libMeadowConnectionMongoDB = require('meadow-connection-mongodb');'.","cause":"Using ES import instead of require(), or package not found.","error":"TypeError: libMeadowConnectionMongoDB is not a constructor"},{"fix":"Run 'npm install meadow-connection-mongodb' and ensure the require path is correct.","cause":"Package not installed or typo in module name.","error":"Error: Cannot find module 'meadow-connection-mongodb'"},{"fix":"Ensure Fable is installed (npm install fable) and instantiated as shown in quickstart.","cause":"Fable library not properly initialized or incorrect version.","error":"TypeError: _Fable.serviceManager.addAndInstantiateServiceType is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/stevenvelozo/meadow-connection-mongodb","github":"https://github.com/stevenvelozo/meadow-connection-mongodb","docs":null,"changelog":null,"pypi":null,"npm":"meadow-connection-mongodb","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}