Skip to content

A simple promises wrapper around mongodb nodejs drivers.

Notifications You must be signed in to change notification settings

swiftsetup/mongodb-promises

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongodb-promises

A simple promises wrapper around mongodb nodejs drivers.

Install

To install the most recent release from npm, run:

npm install mongodb-promises

How to use it?

var db          = require('mongodb-promises').db('host:port', 'db_name'), // host can be array in case of replSet
    todoColl    = db.collection('todos');

todoColl.insert([{text: 'first todo'}, {text: 'second todo'}])
        .then(function (resultArr) {
            console.log('saved successfully');
        })
        .catch(function (err) {
            console.error('Error on insert ', err);
        });

List of DB methods

  • collection(collectionName, options) Returns a collection object to perform operations on a collection using promises.
  • drop() To drop database, call it carefully.
  • createCollection(name, options) Creates a collections on mongodb, usefull if you want collections be created before use(Mongodb can create collection if not exist on first document creation).

List of Collection methods

About

A simple promises wrapper around mongodb nodejs drivers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published