Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Thin wrapper around node-mongodb-native that provides a simpler alternative calling style and provides collection binding.
JavaScript
Tree: ba851c367c

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
Readme.md
index.js
package.json

Readme.md

Introduction

Mongode is a very thin (~200 lines of code) wrapper around the node-mongodb-native driver. It's main purpose is to reduce the amount of function call nesting that is usually needed with the native driver. It does this by buffering commands until the appropriate objects are available.

Installation

npm install mongode

Examples

Insert

node-mongodb-native:

var mongodb = require('mongodb');
var server = new mongodb.Server("127.0.0.1", 27017, {});
new mongodb.Db('test', server, {}).open(function (error, client) {
  if (error) throw error;
  var collection = new mongodb.Collection(client, 'test_collection');
  collection.insert({hello: 'world'}, {safe:true}, function(err, objects) {
    if (err) console.warn(err.message);
  });
});    

mongode:

var mongode = require('mongode');
var db = new mongode.Database('test', 'mongodb://127.0.0.1');
var collection = db.collection('test_collection');
collection.insert({hello: 'world'}, {safe:true}, function(err, objects) {
  if (err) console.warn(err.message);
});
Something went wrong with that request. Please try again.