Comparing version 0.4.4 to 0.4.5
@@ -184,5 +184,3 @@ var mongo = require('mongodb'); | ||
exports.ObjectId = createObjectId; | ||
exports.connect = function(url, collections) { | ||
var connect = function(url, collections) { | ||
url = parse(url); | ||
@@ -203,3 +201,3 @@ collections = collections || url.collections; | ||
var client = new mongo.Db(url.db, replSet || new mongo.Server(url.host, url.port, {auto_reconnect:true})); | ||
var client = new mongo.Db(url.db, replSet || new mongo.Server(url.host, url.port, {auto_reconnect:true}), {safe:false}); | ||
@@ -287,1 +285,4 @@ that.client = client; | ||
exports = module.exports = connect; | ||
exports.ObjectId = createObjectId; | ||
exports.connect = exports; // for backwards compat |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["mongo", "db", "mongodb"], | ||
"version":"0.4.4", | ||
"version":"0.4.5", | ||
"repository": {"type": "git", "url": "git://github.com/gett/mongojs.git"}, | ||
@@ -8,0 +8,0 @@ "author": "Ge.tt <hello@ge.tt>", |
# mongojs | ||
A [node.js](http://nodejs.org) module for mongodb, that emulates [the official mongodb API](http://www.mongodb.org/display/DOCS/Home) as much as possible. It wraps [mongodb-native](https://github.com/christkv/node-mongodb-native/). | ||
A [node.js](http://nodejs.org) module for mongodb, that emulates [the official mongodb API](http://www.mongodb.org/display/DOCS/Home) as much as possible. It wraps [mongodb-native](https://github.com/christkv/node-mongodb-native/). | ||
It is available through npm: | ||
@@ -12,3 +12,4 @@ | ||
``` js | ||
var db = require('mongojs').connect(databaseURL, [collections]); | ||
var mongojs = require('mongojs'); | ||
var db = mongojs(databaseURL, [collections]); | ||
``` | ||
@@ -20,16 +21,16 @@ | ||
// simple usage for a local db | ||
var db = require('mongojs').connect('mydb', ['mycollection']); | ||
var db = mongojs('mydb', ['mycollection']); | ||
// the db is on a remote server (the port default to mongo) | ||
var db = require('mongojs').connect('example.com/mydb', ['mycollection']); | ||
var db = mongojs('example.com/mydb', ['mycollection']); | ||
// we can also provide some credentials | ||
var db = require('mongojs').connect('username:password@example.com/mydb', ['mycollection']); | ||
var db = mongojs('username:password@example.com/mydb', ['mycollection']); | ||
// connect now, and worry about collections later | ||
var db = require('mongojs').connect('mydb'); | ||
var db = mongojs('mydb'); | ||
var mycollection = db.collection('mycollection'); | ||
``` | ||
After we connected we can query or update the database just how we would using the mongo API with the exception that we use a callback | ||
After we connected we can query or update the database just how we would using the mongo API with the exception that we use a callback | ||
The format for callbacks is always `callback(error, value)` where error is null if no exception has occured. | ||
@@ -73,3 +74,3 @@ | ||
``` js | ||
var db = require('mongojs').connect({ | ||
var db = mongojs({ | ||
db: 'mydb', // the name of our database | ||
@@ -76,0 +77,0 @@ collections: ['mycollection'], // we can pass the collections here also |
10562
245
84