Registry / database / mongodb-promise

mongodb-promise

JSON →
library0.0.4jsnpmunverified

A lightweight promise wrapper around the node-mongodb-native driver. Version 0.0.4, last release circa 2014. Provides a thin layer that returns promises for common MongoDB operations like connect, insert, find, and stats. No longer actively developed; the official MongoDB driver now has built-in promise support via async/await. Differentiator: early promise-based interface for MongoDB before the native driver added promises.

npm install mongodb-promise
INSTALL
IMPORT
SIG · MONGODB-PROMISE
M
mongodb-promise
databasejavascriptv0.0.4
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.

mongodb-promise
const mp = require('mongodb-promise');
import mp from 'mongodb-promise';
Package uses CommonJS; no default ESM export.
MongoClient
mp.MongoClient
const { MongoClient } = require('mongodb-promise');
MongoClient is a property of the top-level require, not a named export.
fail
.fail(function(err) { ... })
.catch(function(err) { ... })
Uses Q-style promises. .fail is equivalent to .catch but not standard.

Connects to MongoDB, retrieves database stats, and logs them using promise chaining with .fail for error handling.

const mp = require('mongodb-promise'); mp.MongoClient.connect('mongodb://127.0.0.1:27017/test') .then(function(db) { return db.stats().then(function(stats) { console.log(stats); db.close().then(function() { console.log('closed'); }); }); }) .fail(function(err) { console.error(err); });
Debug
Known issues
gotchaPackage is unmaintained since 2014. Use the official MongoDB driver's built-in promise support instead.
fix
Use mongodb driver v2+: const MongoClient = require('mongodb').MongoClient;
affects: >=0.0.0
deprecatedUses non-standard .fail() method which is not Promise/A+ compliant. May break in promise polyfills.
fix
Replace .fail() with .catch() if you can customize, or avoid this library.
affects: >=0.0.0
gotchadb.collection() returns a promise, not a collection object like in modern drivers.
fix
Always chain .then() on db.collection() before using the collection.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'mongodb-promise'
Package not installed or typo in require path.
fix
npm install mongodb-promise --save
TypeError: mp.MongoClient.connect(...).then is not a function
Using an outdated version where connect does not return a promise.
fix
Ensure you are using version 0.0.4 or later.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
mongodb-promise — npm install mongodb-promise · libregistry