q-mongodb

Q (promises) wrapper for the mongodb node.js package

npm install q-mongodb
1 downloads in the last day
3 downloads in the last week
15 downloads in the last month

Introduction

This is a node.js module which wraps the mongodb module with the q promises module. It handles opening a db (and maintaining the open db object) as well as accessing collections (creating them if need be). If you query for the same db multiple times during the lifetime of your node app, you'll be handed the same open db object (unless you explicitly close the db with a call to closeAll()).

Usage

var QMongoDB = require('q-mongodb');

QMongoDB.db('my_db').then(function(db) {
    return QMongoDB.collection(db, 'people');
}).then(function(collection) {
    // Perform standard collection operations here
}).then(function() {
    return QMongoDB.closeAll();
});
npm loves you