Skip to content

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

Notifications You must be signed in to change notification settings

shin-/node-mongodb-wrapper

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%