Registry / database / mongoclient

mongoclient

JSON →
library1.0.3jsnpmunverified

A lightweight Mongoose wrapper for MongoDB v1.0.3. Provides a thin client layer around Mongoose for quick connection setup with minimal configuration. Active but limited release cadence; last update was several years ago. Not to be confused with the official MongoDB Node.js driver's MongoClient; this package is specifically a wrapper for Mongoose.

npm install mongoclient
INSTALL
IMPORT
SIG · MONGOCLIENT
M
mongoclient
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
import mongoClient from 'mongoclient'
const mongoClient = require('mongoclient')
Package uses CommonJS module.exports, so ESM import works as default import. Wrong pattern shown above will actually work in Node.js CJS, but 'wrong' is meant for common pitfalls; here the CJS require is correct. This entry is intentionally left as an example of typical ESM usage.
default (CJS)
const mongoClient = require('mongoclient')
const { mongoClient } = require('mongoclient')
Package exports a single function as module.exports. Do not destructure.
TypeScript type
import mongoClient from 'mongoclient'; // no types shipped
import { MongoClient } from 'mongoclient'
Package does not include TypeScript definitions. Use @types/mongoclient if available, or declare your own.

Shows basic usage: configure MongoDB URI and connect using the wrapper.

const config = { mongo: { uri: 'mongodb://127.0.0.1:27017/hello-world', }, }; const mongoose = require('mongoose'); const mongoClient = require('mongoclient'); // Initialize connection mongoClient(config).then(() => { console.log('Connected to MongoDB'); }).catch(err => { console.error('Connection error:', err); });
Debug
Known issues
deprecatedPackage uses older Mongoose APIs. May not work with Mongoose >=6.
fix
Upgrade to Mongoose 5.x or test compatibility; consider using Mongoose directly.
affects: >=1.0.0
gotchaConfiguration expects a nested `mongo` object with `uri` property. Passing a flat object will fail silently.
fix
Ensure config object has the shape: { mongo: { uri: '...' } }
affects: >=1.0.0
gotchaNo error handling for invalid URIs; connection may hang.
fix
Add try/catch around client call or use mongoose.connect() directly for better error handling.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'connect' of undefined
Package expects mongoose to be installed and configured globally, but it's missing or not initialized.
fix
Run 'npm install mongoose' and ensure mongoose is available in the project.
MongoClient is not a constructor
Attempting to use new MongoClient() instead of calling the default function.
fix
Replace 'new MongoClient(config)' with 'mongoClient(config)' or 'require('mongoclient')(config)'
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
mongooserequiredCore dependency for MongoDB ODM functionality
Agent activity
5 hits · last 30 days
node
4
Resources
mongoclient — npm install mongoclient · libregistry