A wrapper for node-mongodb-native as close as possible to the command-line javascript driver. Why learn two interfaces?
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 41 commits behind idottv:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
Readme.md
index.js
package.json
test.js

Readme.md

node-mongodb-wrapper

A wrapper for node-mongodb-native as close as possible to the native javascript driver. Why learn two interfaces?

Yes, we know other people are doing the same thing. This one has been easier to use.

Features

  1. Minimal interface closely matching the command-line driver: http://www.mongodb.org/display/DOCS/Manual
  2. Lazy open/close of connections
  3. Most features of node-mongodb-native

Features it doesn't have

  1. Connection pooling. Each db will share a single connection.

Installation

  npm install mongodb-wrapper

Usage

  1. You have to tell the db object which collections you're about to use (Harmony Proxies, I need you!)
  2. You have to provide callbacks on "actionable" calls (toArray, count, but not find)
  3. Otherwise, just like the native javascript driver
	var mongo = require('mongodb-wrapper')
	var db = mongo.db('localhost', 27017, 'test')
	db.collection('posts')
	
	db.posts.save({title: "A new post", body: "Here is some text"}, function(err, post) {
		db.posts.findOne({_id: doc._id}, function(err, post) {
			db.posts.find().limit(1).toArray(function(err, posts) {
				// posts[0].title == "A new post"
			})
		})
	})      

For more examples, please look at the test suite