Registry / database / bem-mongodb-connection

bem-mongodb-connection

JSON →
library1.0.22jsnpmunverified

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.

npm install bem-mongodb-connection
INSTALL
IMPORT
SIG · BEM-MONGODB-CONNEC
B
bem-mongodb-connection
databasejavascriptv1.0.22
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.

connect
import { connect } from 'bem-mongodb-connection'
const connect = require('bem-mongodb-connection').connect
ESM export; CJS require with destructuring may work
default
import connection from 'bem-mongodb-connection'
const connection = require('bem-mongodb-connection')
Default export returns a connection object; CJS require gives the default
getConnection
import { getConnection } from 'bem-mongodb-connection'
import getConnection from 'bem-mongodb-connection'
Named export, not default

Shows basic connection to MongoDB using environment variable for URI and a findOne operation.

import { connect } from 'bem-mongodb-connection'; async function main() { const uri = process.env.MONGO_URI ?? 'mongodb://localhost:27017/mydb'; try { const db = await connect(uri); console.log('Connected successfully'); // Use db object for operations const result = await db.collection('users').findOne({}); console.log(result); } catch (err) { console.error('Connection failed:', err); } } main();
Debug
Known issues
gotchaPackage has no README or examples; usage based on source inspection.
fix
Review source code in node_modules to understand API
affects: >=1.0.0
deprecatedNo updates in over 2 years; may rely on older MongoDB driver.
fix
Consider using Mongoose or the official MongoDB driver directly
affects: >=1.0.22
gotchaConnection does not handle reconnection automatically; you must implement retry logic.
fix
Wrap in try/catch and reconnect on failure
affects: >=1.0.0
breakingDefault export changed between versions; verify your import pattern.
fix
Use named import { connect } instead of default
affects: <=1.0.20
Errors
Common errors & fixes
Cannot find module 'bem-mongodb-connection'
Package not installed or missing from package.json
fix
npm install bem-mongodb-connection
connect is not a function
Incorrect import style; using default import when named export expected
fix
Use import { connect } from 'bem-mongodb-connection'
TypeError: Cannot read properties of undefined (reading 'collection')
Connection failed or db object null
fix
Check connection URI and handle errors asynchronously
Upgrade
Version history
1.0.22latest on npm
Audit
Dependencies
mongodbrequiredCore dependency for MongoDB driver
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
bem-mongodb-connection — npm install bem-mongodb-connection · libregistry