{"id":42448,"library":"bem-mongodb-connection","title":"BEM MongoDB Connection","description":"A lightweight MongoDB connection helper for Node.js applications. Version 1.0.22 provides a simple wrapper around the native MongoDB driver to establish and manage database connections with minimal configuration. It offers basic connection pooling and URI parsing. Development appears infrequent with no recent updates, and the package lacks documentation. Simpler than Mongoose but without schema validation or middleware.","status":"maintenance","version":"1.0.22","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install bem-mongodb-connection","lang":"bash","label":"npm"},{"cmd":"yarn add bem-mongodb-connection","lang":"bash","label":"yarn"},{"cmd":"pnpm add bem-mongodb-connection","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for MongoDB driver","package":"mongodb","optional":false}],"imports":[{"note":"ESM export; CJS require with destructuring may work","wrong":"const connect = require('bem-mongodb-connection').connect","symbol":"connect","correct":"import { connect } from 'bem-mongodb-connection'"},{"note":"Default export returns a connection object; CJS require gives the default","wrong":"const connection = require('bem-mongodb-connection')","symbol":"default","correct":"import connection from 'bem-mongodb-connection'"},{"note":"Named export, not default","wrong":"import getConnection from 'bem-mongodb-connection'","symbol":"getConnection","correct":"import { getConnection } from 'bem-mongodb-connection'"}],"quickstart":{"code":"import { connect } from 'bem-mongodb-connection';\n\nasync function main() {\n  const uri = process.env.MONGO_URI ?? 'mongodb://localhost:27017/mydb';\n  try {\n    const db = await connect(uri);\n    console.log('Connected successfully');\n    // Use db object for operations\n    const result = await db.collection('users').findOne({});\n    console.log(result);\n  } catch (err) {\n    console.error('Connection failed:', err);\n  }\n}\n\nmain();","lang":"typescript","description":"Shows basic connection to MongoDB using environment variable for URI and a findOne operation."},"warnings":[{"fix":"Review source code in node_modules to understand API","message":"Package has no README or examples; usage based on source inspection.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using Mongoose or the official MongoDB driver directly","message":"No updates in over 2 years; may rely on older MongoDB driver.","severity":"deprecated","affected_versions":">=1.0.22"},{"fix":"Wrap in try/catch and reconnect on failure","message":"Connection does not handle reconnection automatically; you must implement retry logic.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use named import { connect } instead of default","message":"Default export changed between versions; verify your import pattern.","severity":"breaking","affected_versions":"<=1.0.20"}],"env_vars":null,"search_vec":"'1.0.22':13 'appear':41 'applic':11 'around':18 'basic':34 'bem':1 'configur':31 'connect':3,7,28,35 'databas':27 'develop':40 'document':51 'driver':22 'establish':24 'helper':8 'infrequ':42 'javascript':61 'lack':50 'lightweight':5 'manag':26 'middlewar':60 'minim':30 'mongodb':2,6,21 'mongoos':54 'nativ':20 'node.js':10 'offer':33 'packag':49 'pars':39 'pool':36 'provid':14 'recent':45 'schema':57 'simpl':16 'simpler':52 'updat':46 'uri':38 'valid':58 'version':12 'without':56 'wrapper':17","created_at":"2026-06-05T16:55:02.828204+00:00","updated_at":"2026-06-05T16:55:02.828204+00:00","problems":[{"fix":"npm install bem-mongodb-connection","cause":"Package not installed or missing from package.json","error":"Cannot find module 'bem-mongodb-connection'"},{"fix":"Use import { connect } from 'bem-mongodb-connection'","cause":"Incorrect import style; using default import when named export expected","error":"connect is not a function"},{"fix":"Check connection URI and handle errors asynchronously","cause":"Connection failed or db object null","error":"TypeError: Cannot read properties of undefined (reading 'collection')"}],"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://gitlab.com/bemcloud/mongodb-connection#README","github":null,"docs":null,"changelog":null,"pypi":null,"npm":"bem-mongodb-connection","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}}