Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

mongojs

mongo-js45.1kMIT3.1.0

Easy to use module that implements the mongo api

mongo, db, mongodb

readme

mongojs

A node.js module for mongodb, that emulates the official mongodb API as much as possible. It wraps mongodb-native and is available through npm

npm install mongojs

Build Status js-standard-style

Usage

mongojs is easy to use:

const mongojs = require('mongojs')
const db = mongojs(connectionString, [collections])

The connection string should follow the format described in the mongo connection string docs. Some examples of this could be:

// simple usage for a local db
const db = mongojs('mydb', ['mycollection'])

// the db is on a remote server (the port default to mongo)
const db = mongojs('example.com/mydb', ['mycollection'])

// we can also provide some credentials
const db = mongojs('username:password@example.com/mydb', ['mycollection'])

// connect using SCRAM-SHA-1 mechanism
const db = mongojs('username:password@example.com/mydb?authMechanism=SCRAM-SHA-1', ['mycollection'])

// connect using a different auth source
const db = mongojs('username:password@example.com/mydb?authSource=authdb', ['mycollection'])

// connect with options
const db = mongojs('username:password@example.com/mydb', ['mycollection'], { ssl: true })

// connect now, and worry about collections later
const db = mongojs('mydb')
const mycollection = db.collection('mycollection')

More connection string examples

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. The update methods save, remove, update and findAndModify also pass the lastErrorObject as the last argument to the callback function.

// find everything
db.mycollection.find(function (err, docs) {
    // docs is an array of all the documents in mycollection
})

// find everything, but sort by name
db.mycollection.find().sort({name: 1}, function (err, docs) {
    // docs is now a sorted array
})

// iterate over all whose level is greater than 90.
db.mycollection.find({level: {$gt: 90}}).forEach(function (err, doc) {
    if (!doc) {
        // we visited all docs in the collection
        return
    }
    // doc is a document in the collection
})

// find a document using a native ObjectId
db.mycollection.findOne({
    _id: mongojs.ObjectId('523209c4561c640000000001')
}, function(err, doc) {
    // doc._id.toString() === '523209c4561c640000000001'
})

// find all named 'mathias' and increment their level
db.mycollection.update({name: 'mathias'}, {$inc: {level: 1}}, {multi: true}, function () {
    // the update is complete
})

// find one named 'mathias', tag him as a contributor and return the modified doc
db.mycollection.findAndModify({
    query: { name: 'mathias' },
    update: { $set: { tag: 'maintainer' } },
    new: true
}, function (err, doc, lastErrorObject) {
    // doc.tag === 'maintainer'
})


// use the save function to just save a document (callback is optional for all writes)
db.mycollection.save({created: 'just now'})

If you provide a callback to find or any cursor config operation mongojs will call toArray for you

db.mycollection.find({}, function (err, docs) { ... })

db.mycollection.find({}).limit(2).skip(1, function (err, docs) { ... })

is the same as

db.mycollection.find({}).toArray(function (err, docs) { ... })

db.mycollection.find({}).limit(2).skip(1).toArray(function (err, docs) { ... })

For more detailed information about the different usages of update and querying see the mongo docs

Events

const db = mongojs('mydb', ['mycollection'])

db.on('error', function (err) {
    console.log('database error', err)
})

db.on('connect', function () {
    console.log('database connected')
})

Streaming cursors

As of 0.7.0 all cursors are a readable stream of objects.

const JSONStream = require('JSONStream')

// pipe all documents in mycollection to stdout
db.mycollection.find({}).pipe(JSONStream.stringify()).pipe(process.stdout)

Notice that you should pipe the cursor through a stringifier (like JSONStream) if you want to pipe it to a serial stream like a http response.

Tailable cursors

If you are using a capped collection you can create a tailable cursor to that collection by adding tailable:true to the find options

const cursor = db.mycollection.find({}, {}, {tailable: true, timeout: false})

// since all cursors are streams we can just listen for data
cursor.on('data', function (doc) {
    console.log('new document', doc)
})

Note that you need to explicitly set the selection parameter in the find call.

Database commands

With mongojs you can run database commands just like with the mongo shell using db.runCommand()

db.runCommand({ping: 1}, function (err, res) {
    if(!err && res.ok) console.log('we\'re up')
})

or db.collection.runCommand()

db.things.runCommand('count', function (err, res) {
    console.log(res)
})

Bulk updates

As of 0.15 mongojs supports the Bulk updates introduced in mongodb 2.6. Here's an example of the usage

const bulk = db.a.initializeOrderedBulkOp()
bulk.find({type: 'water'}).update({$set: {level: 1}})
bulk.find({type: 'water'}).update({$inc: {level: 2}})
bulk.insert({name: 'Spearow', type: 'flying'})
bulk.insert({name: 'Pidgeotto', type: 'flying'})
bulk.insert({name: 'Charmeleon', type: 'fire'})
bulk.find({type: 'flying'}).removeOne()
bulk.find({type: 'fire'}).remove()
bulk.find({type: 'water'}).updateOne({$set: {hp: 100}})

bulk.execute(function (err, res) {
  console.log('Done!')
})

Replication Sets

Mongojs can also connect to a mongo replication set by providing a connection string with multiple hosts

const db = mongojs('rs-1.com,rs-2.com,rs-3.com/mydb?slaveOk=true', ['mycollection'])

For more detailed information about replica sets see the mongo replication docs

Using harmony features

If you run node.js with the --harmony option, then you can ommit the collection names array, and you can do stuff like.

const mongojs = require('mongojs')
const db = require('mydb')

db.hackers.insert({name: 'Ed'})

In the above example the hackers collection is enabled automagically (similar to the shell) using the Proxy feature in harmony

Passing a DB to the constructor

If you have an instance of mongojs, you can pass this to the constructor and mongojs will use the existing connection of that instance instead of creating a new one.

const mongodb = require('mongodb')
const mongojs = require('mongojs')

mongodb.Db.connect('mongodb://localhost/test', function (err, theDb) {
    const db = mongojs(theDb, ['myCollection'])
})

Features not supported for MongoDB 2.4 or older (on mongojs version 1.0+).

  • Index creation and deletion
  • Aggregation cursors.

This features are relatively easy to add, but would make the code unnecessarily more complex. If you are using mongodb 2.4 or older and would like to use mongojs 1.0 with the above mentioned feautres, feel free to make a pull request or open and issue..

Upgrading from 0.x.x to 1.2.x

Version > 1.0.x is a major rewrite of mongojs. So expect some things not to work the same as in mongojs 0.x.x versions. Breaking changes include:

  • Removed mongojs.connect use mongojs() directly instead

API

This API documentation is a work in progress.

Collection

db.collection.aggregate([pipeline], [options], [callback])

https://docs.mongodb.org/manual/reference/method/db.collection.aggregate/

db.collection.aggregate([pipelineStep], [pipelineStep], [pipelineStep], ..., [callback])
db.collection.count([query], callback)
db.collection.createIndex(keys, options, [callback])
db.collection.distinct(field, query, callback)
db.collection.drop([callback])
db.collection.dropIndex(index, [callback])
db.collection.dropIndexes([callback])
db.collection.ensureIndex(keys, options, [callback])
db.collection.find([criteria], [projection], [callback])

This function applies a query to a collection. You can get the return value, which is a cursor, or pass a callback as the last parameter. Said callback receives (err, documents)

db.collection.findOne([criteria], [projection], callback)

Apply a query and get one single document passed as a callback. The callback receives (err, document)

db.collection.findAndModify(document, callback)
db.collection.getIndexes(callback)
db.collection.group(document, callback)
db.collection.insert(docOrDocs, [callback])
db.collection.isCapped(callback)
db.collection.mapReduce(map, reduce, options, [callback])
db.collection.reIndex([callback])
db.collection.remove(query, [justOne], [callback])
db.collection.remove(query, [options], [callback])
db.collection.runCommand(command, [callback])
db.collection.save(doc, [options], [callback])
db.collection.stats(callback)
db.collection.update(query, update, [options], [callback])
db.collection.toString()

Get the name of the collection.

Cursor

cursor.batchSize(size, [callback])
cursor.count(callback)
cursor.explain(callback)
cursor.forEach(function)
cursor.limit(n, [callback])
cursor.map(function, [callback])
cursor.next(callback)
cursor.skip(n, [callback])
cursor.sort(sortOptions, [callback])
cursor.toArray(callback)
cursor.rewind()
cursor.destroy()

Database

db.addUser(document)
db.createCollection(name, options, [callback])
db.dropDatabase([callback])
db.eval(code, [params], [options], [callback])
db.getCollectionNames(callback)
db.getLastError(callback)
db.getLastErrorObj(callback)
db.removeUser(username, [callback])
db.runCommand(command, [callback])
db.stats([callback])
db.close()

Bulk

bulk.execute()
bulk.find(query)
bulk.find.remove()
bulk.find.removeOne()
bulk.find.replaceOne(document)
bulk.find.update(updaterParam)
bulk.find.updateOne(updaterParam)
bulk.find.upsert(upsertParam)
bulk.insert(document)
bulk.toString()
bulk.tojson()

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

v3.1.0

31 October 2019

  • Add replaceOne support, fix collection.save #382
  • Set theme jekyll-theme-cayman 24b58c6
  • Set theme jekyll-theme-minimal d155c4a

v3.0.0

20 October 2019

  • Publicly expose mongo BSON Map (ES5 polyfill) #364
  • Replaces xtend dependency by Object.assign #380
  • removes shelljs dependency #379
  • Expose Decimal128 BSON type #362
  • Publicly expose mongo BSON Int32 type #363
  • update var to const #361
  • Update dependencies #377
  • Upgrade mongodb to version ^3. #353
  • Add package lock file 3be25ef
  • Remove package-lock.json as it breaks builds due to a bug in npm with bundleDependencies and shoe 747f270
  • Generate a new changelog with auto-changelog 9a39edd
  • Switch to nyc for coverage reports c516e92
  • Add auto-changelog to dependencies and to release workflow 0552311
  • Implement updateOne, insertOne and updateMany, insertMany d23f0ee
  • Fix connection string extension with mongodb+srv protocol 106af3e
  • Fix release script d0f139b
  • Reflect the move to the mongo-js organization in URLs 2664828
  • Remove support for node v0.10, v0.12 from travis build matrix and add v9 and v10 to build matrix e0ab473
  • Add mongodb 4 to build matrix a318000

v2.6.0

29 May 2018

v2.5.0

4 February 2018

  • Work around for property 'Symbol(Symbol.toPrimitive)' in Proxy handler #332
  • Add deleted count property to the return object of the .remove method #318
  • Adds support for ES6 default module import syntax #327
  • Fixes #265 by breaking operations if max bulk size is exceeded #265
  • Update changelog fixes #311 #303 #311
  • Add test to verify issue #337 d163d84
  • Execute geotag pkg optional 120889b
  • Update dependencies 58f8792
  • Add node 7 and 8 and mongodb 3.4 to build matrix and update mongodb versions 173a569
  • Update standard and fix code style issues ca97026
  • Adapt to exec shelljs api changes fc65ed0
  • Use === instead of == to please the standard 7c3bcda
  • Use cursor sort order to avoid tests fail due to sort order 54d99cb
  • Update mongodb dependency 197c10e

v2.4.1

8 August 2017

  • Fix Markdown #334
  • Update thunky to version ^1.0.2 to fix #321 #321
  • Fix problem that newer versions of mongodb do not expose connection url in options c5e170d
  • Newer versions of mongo native driver don't store the database name the same way. faabd09
  • Geotag package for release d36a150
  • Fix code style 642b2ff
  • Work around for property 'Symbol(Symbol.toPrimitive)' with node v6.x or higher version 05ac3d1
  • Adds support for ES6 default module import syntax e4b7a1c
  • add deletedCount property to return object from remove method 0f9a18b
  • Add deletedCount property to return result from the .remove method 7f3b9d9
  • added the deletedCount property to the return object from the remove method. This is valuable information when creating Restful APIs. 895626d

v2.4.0

28 April 2016

  • Fix for node 6 #301
  • Updated readme with connection options example #298
  • Added test case find-sort-many #295
  • Make Bulk.toString() actually return a string #276
  • Saintedlama/travis non legacy #285
  • Run tests with tap-spec #284
  • Added (failing) test case find-sort-many to demonstrate that sort does not work for more than 1000 results 459a5f9
  • Add test for rename 5bd21c9
  • Fixed indentation to use spaces df12488
  • Adjust code style in argument sanitizing 9340152
  • Geotag package for release 0868f67
  • Temporary bug fix for tape sporadic errors - see https://github.com/substack/tape/issues/223 eaae970
  • Fix PR #280 8751669
  • Style changed to be compliant with javascript standard style e7492e9
  • Remove semicolons e0a4d8d
  • Return the created proxy instead of assigning it to a var p 9a34051
  • Update dev dependencies 5dcbb67
  • Fix shelljs output check a95f946
  • Fix coding style c2060be
  • Remove semicolon 2ead974
  • Check if opts is a function so a callback can be passed as second argument 459b81c
  • Remove mongodb 2.4 from test matrix due to compatibility issues c6f9d74
  • Add node.js 6 to travis build matrix 9f892e2

v2.3.0

14 January 2016

  • Wrapper to rename a collection #280
  • add one more test case for #217 dot in collections #277
  • Added wrapper to rename a collection 56d3b82
  • Geotag package for release 0f58aa6
  • Fix test for bulk.toString 449a691
  • no message 669974d
  • Make Bulk.toString() actually return a string bbe332b

v2.2.2

15 December 2015

  • Fix handling default arguments in ensureIndex #274
  • Add test to verify collections with a dot are working. Closes #217 #217
  • Add changelog generated with github-changes npm module 26560c8
  • Move to non legacy infrastructure of travis bf433ea
  • Geotag package for release 46fae76
  • Pipe output to dev/null 5bb2262
  • Move waiting for mongodb to first before script 6777dd2
  • Remove mongodb 2.8.0 704378f

v2.2.1

15 December 2015

  • Fix #270 by using process.nextTick in loop #270
  • Add feature to pass options to aggregate. Closes #249 #249
  • Add test to test queries in large collections to reproduce possible stack trace maximum exceeded errors 04d1231
  • Geotag package for release 9cd87a5
  • Use setImmediate(loop) instead of process.nextTick(loop) to please node 0.10 5a7b643
  • Cleanup test b6a755b
  • Add documentation for db.collection.aggregate with options including mongodb documentation link 3b8fe9b
  • Remove unused callback "done" 79cac0b
  • Remove superfluous dependency "pump" 23000f2

v2.2.0

14 December 2015

  • Add bulk.toString() and bulk.find.replaceOne(), update doc #272
  • Fix bulk to json function, add tests to this function #269
  • Add tests for bulk.toString and bulk.find.replaceOne 670bc71
  • Use mongodb-native mapReduce implementation 9729a4d
  • Rename options argument to opts to match code style 0345349
  • Allow passing opts including writeOps to save 77eef29
  • Rename cursor tests to fit naming schema d4dbdb7
  • Geotag package for release 6f3a303
  • Rename map reduce tests a368c1f
  • Update readme to reflect new version 2.x b7a27aa
  • Align collection.prototype.save argument correction style to mongojs code style 6b6e2df
  • Merge opts with default writeOps in update edb5b6d
  • Add documentation for aggregate 865d6e6
  • Add documentation stub for db.collection.remove with options object 60573fc

v2.1.0

9 December 2015

  • Added support for finalize in mapReduce #253
  • Add shelljs based release script 1f72797
  • Fix pushing null commands to bulk pipeline in case no bulk operation was added 1248b5e
  • Rely on mongodb native ensure index and create index commands and compatibility handling for mongodb versions < 2.8 3e19869
  • Implement listCollections and use listCollections to implement getCollectionNames 4c407e3
  • Fix code style to adhere to the standard b5e5632
  • Geotag package for release a38dc6d
  • Implement some missing cursor methods 9b77c8d
  • Add option to execute a bulk without passing a callback function 08e8d99
  • Add back check for git status in release script e64ef5c
  • Run the correct script to geo tag the pkg. Really! 303c2f9
  • Adhere to the standard 7b27dc6
  • Implement optional callback in db.collection.remove 709f67a
  • Run geopkg npm script correctly 9d87de7
  • Correct connection string examples URL 6d365d2

v2.0.0

2 December 2015

  • Use mongodb-native instead of mongodb-core driver #256
  • Increase coverage by adding tests for eval, drop database, db stats, create and drop users 37c690b
  • Introduce getCollection to avoid duplicate _getConnection + connection.collection(this.fullName) code 44b8ee8
  • Generate functions to set limit, batchSize, sort and skip 3d375f8
  • Make database an EventEmitter and emit events for error and connect cb70b55
  • Add tests for mongojs bson type exports ea1b07a
  • Fix connection string building for connection strings omitting mongodb:// prefix or host of db cb973f0
  • Add tests for connection string parsing f9ab363
  • Simplify remove 67acfa2
  • Fix code style to match standard version 5 code style 54a9ab9
  • Test toString implementations for mongos and replica set connection strings 6e182e3
  • Cleanup getCollectionNames implementation by using mongodb-native functionality f49c38e
  • Remove duplicate code from aggregate bbb030c
  • Remove destroy event test 11b513d
  • Correct connecting section 689f161
  • Update dependencies and move to standard version 5 0268423
  • Implement workaround for harmony proxy in combination with event emitter inheritance 56f1eb8
  • Fix checks for insert and 7b01fa9
  • Make checking for err object less verbose d079280
  • Adhere to standard code style 6f5ecd0
  • Run geotag update instead of plain geotag in geotag npm script 3c59a49
  • Call EventEmitter constructor 26cc395
  • Clarify comment f240a7e
  • Add a connection error handler 3426d64
  • Expose NumberLong alias for shell compatibility c864aef
  • Ignore vi temporary files 99811b5
  • Test mongojs in node.js 5 environments 12a639c

v1.4.1

12 October 2015

  • Use mongodb instead of mongodb-core and add minimal test to require mongojs and access all bson types 3026b7f
  • Implement basic functionality to insert and remove documents to drive all further tests 246976e
  • Implement mongojs and mongodb-native connection passing 60297a3
  • Implement aggregations 73a79ac
  • Implement find using cursor 4257022
  • Fix code style issues bae604e
  • Implement cursor operations 482cb84
  • Add support for finalize in mapReduce c67fbbf
  • Implement group 31d98d2
  • Implement update and getIndexes 1df7336
  • Add test to verify that connecting to a non existing database yields an error in the provided operation callback 48a00df
  • Test stats 37c2fb5
  • Implement isCapped 180abe8
  • Implement bulk operations e5a60d1
  • Implement passing mongojs connections 3a89ec7
  • Fix distinct tests ac5c2fc
  • Fix next implementation by checking if the cursor was closed and quite in a graceful manner 143c836
  • Implement command execution on collection level 749dfd7
  • Implement close b66eb5b
  • Implement cursor destroy/close d95e6a6
  • Add TODO concerning command interface hits bad1461
  • Fix code style issues d461975
  • Rename ready event to connect in README.md 6341c35
  • Fix code style 54bae03

v1.4.0

6 October 2015

  • Expose bson stuff visible in the shell #251
  • Fix build of MongoDB >2.4 on Travis ebf6bc8
  • Run tests against Node.js v4.x instead of iojs 0e1b573

v1.3.0

14 August 2015

  • Fixed insert error detection and passing #237
  • Return on connection error #240
  • Implement events #229
  • Add test for pull request #237 "Fixed insert error detection and passing" 469f48c
  • Merge options and connString + cols object into options object f11bcd1
  • Add test to assure an unopened db can be closed bf7473e
  • Pass options to mongodb topology instance constructor 27939a7
  • Fix upgrading section 9d49f53
  • Added more existence checks to insert d2773ec
  • Insert final newline to adhere to standard code style 8d06cfe
  • Remove events not working from Upgrading notice ba18f23

v1.2.1

26 July 2015

  • Upgrade dependencies #228
  • Practise what we preach: Use standard code style in examples 7b163a9
  • Add contribution guidelines 885d529
  • Clean up README.md 8c4a2df
  • Add editorconfig 8a6c786
  • Upgrade all dev-dependency modules a0caa82
  • No need to use custom npm version when node.js v0.8 isn't tested 581a6db
  • Fix Travis-CI build to properly test against MongoDB 3.0 af83bf0
  • Add warning block for MongoDB 3 auth 578dcc7
  • Bump copyright year 3795d14

v1.2.0

25 July 2015

  • Implement the 'standard' linter #227
  • Remove semicolons e7146c8
  • Insert space before function opening bracket 8945d41
  • Insert space between colon and value in object literals e59971e
  • Use t.error to handle errors instead of t.ok(!err) and friends 65b7acf
  • Remove spaces before comma fcce1f7
  • Use single quotes when defining strings 1372ed6
  • Handle all errors 481935a
  • Insert space between comma and next value b00dabb
  • Remove spaces before colon in object literals 7b56b0f
  • Remove trailing spaces 737ceb8
  • Remove unused variables 90af4b4
  • Don't overwrite setImmediate 6912f95
  • Don't run subsequent tests if previous tests fail 14d3e0c
  • Don't assign while returning 2a589ae
  • Add standard test 195ffce
  • Add Thomas Watson as contributer 0945e27
  • Ensure while loops evaluate a conditional expression ac9f4db
  • Upgrade readable-stream to ^2.0.2 933eacb
  • Remove trailing comma in object literal 31ea45e
  • Insert proper spaces in ternaries 60c1036
  • Disable linter for problematic JavaScript running inside MongoDB 8973b36
  • Add space before opening function curly brackets 560795b
  • Fix indentation e964661
  • Add standard code style badge to README.md a61b451
  • remove tip jar 9924c3b

v1.1.0

25 July 2015

  • Add support for ScramSHA1 #209
  • Add upsert() method for Bulk.find #213
  • Allow array-based aggregation pipelines #204
  • add support for SCRAM-SHA-1 auth mechanism. c9025bb
  • Fix naming and reference ScamSHA1 via mongodb.ScamSHA1 ec3ef7d
  • Added tests for upsert() method 2bcbed3
  • Add npm run geotag script 772dff2
  • Add "npm run cover" command using istanbul for coverage and ignore coverage dir fa90791
  • Add "Upgrading from 0.x.x to 1.0.x" section e1157b0
  • Close connection to test closing connections 7c4cad4
  • Fix harmony tests and coverage commands by adding --harmony-proxies flag to enable Proxy functionality d467340
  • Split set upsert to true and return this for readability 5d96ebb
  • Remove superfluous ; 2f0c62b
  • Remove unused require('each-series') d4bf755
  • Add aggregation pipeline breaking changes to Upgrading from 0.x.x to 1.0.x 70d6bc5

v1.0.2

27 June 2015

  • Add upsert() method for Bulk.find #1
  • Add check for cb undefined in createIndex #203
  • Use cursor.kill instead of cursor.close #207
  • Allow array-base aggregation pipelines 7dd97fd
  • Update bulk.js 15c053b
  • Test all branches on Travis-CI 63a4b7b
  • Test against Node.js 0.12 instead of 0.11 on Travis CI 0b01039
  • Use Number.MAX_VALUE instead of -1 for tailable cursor retries. aebc43c
  • Update to latest mongodb-core. 030d585
  • Use SVG build status from travis master branch builds 453b522
  • Add check for cb undefined to prevent calls to ensureIndex with index field and options given but without cb throw an error 9eae343

v1.0.1

16 June 2015

  • Update mongodb-core patch level #198
  • Update mongodb-core patch level. 4443c94

v1.0.0

10 June 2015

  • Added back tailable cursor support. #194
  • Add license field to package.json #195
  • Update travis to use recent mongodb versions and iojs. bf9b801

v1.0.0-beta4

2 May 2015

  • Cleanup. Removed unused vars and imports #188
  • Removed unused noop 0c5698b
  • Expose ObjectId in module. 63496e8
  • Test on io.js 67235a3

v1.0.0-beta3

21 March 2015

  • Always use readable-stream. f279cbb

v1.0.0-beta2

21 March 2015

  • Remove unused dependency and stop using cursor._apply. 23c1a82
  • Update deps. 4291eec
  • Fix foreach. c9f5d92
  • Check for last error on foreach. a27cdcc

v1.0.0-beta1

21 March 2015

  • mongodb-core rewrite. 0324967
  • Add some docs for 1.0 with mongodb 2.4 a167c18

v0.18.2

2 March 2015

  • Update to mongodb 1.4.32 #182
  • Change Travis-CI badge to only show master status #177
  • Allow travis builds for other branches. a598537

v0.18.1

17 January 2015

  • Allow to call bulk.update() without callback. Fixes #166. #166
  • Add docs for readPref, Fixes #165 #165

v0.18.0

9 December 2014

v0.17.0

7 November 2014

v0.16.0

7 November 2014

  • Make aggregate return a stream. Fixes #154. #154
  • Bump driver. c533e5a
  • Remove toJSON function ae77aa6

v0.15.1

5 October 2014

  • Ignore bulk tests in case db version < 2.6 (travis). de4f9a4

v0.15.0

5 October 2014

  • Emit error on connection error. Closes #149 #149
  • Add support for bulk updates. Refs #152 a025aa2
  • Docs for bulk updates d52e1ea
  • Bump driver. 76ecb43

v0.14.2

26 September 2014

v0.14.1

28 August 2014

  • Add cursor API docs for .rewind() and .destroy() #147
  • Refactor tests so you can run them individually and they exit. abab80b
  • Bump driver. 4a73373
  • Fix tests for 0.8. 03b90eb

v0.14.0

20 August 2014

  • Add API documentation for db.close() #146
  • Give me some space. f46c14e
  • Refactor tests to use tape. e560204
  • Add support to pass a driver db or a mongojs db instead of the connection string. 940dff5
  • If we receive a mongojs instance we connect and recreate the instance, 94622be
  • Update docs. ebb6b02
  • Restructure the group function to multiple lines. d42d7a0
  • Minor test refactor. f1ded41
  • ocd. b5c140c
  • Minor refactor. a16dd33
  • Fix travis. b2f3bbd
  • Fix api docs for getCollectionNames. Refs #54 79319b4

v0.13.1

25 July 2014

v0.13.0

26 April 2014

  • Collection proxy with harmony. c6e8f5c
  • Run both with and without --harmony on every node version. c62133a
  • Document the harmony proxy feature. 8a6fa48
  • Add node 0.11 to travis. 1aeaba2

v0.12.1

19 April 2014

  • ensure optional callbacks for write ops. cc #135 20e4b33
  • tweak docs for #135 edaae8f
  • added test for optional callbacks. cc #135 d2be4b9

v0.12.0

16 April 2014

  • Stop inhereting collection prototype methods. Fixes #132. #132
  • Stop inhereting db prototype methods. Refs #132. 809252c

v0.11.1

9 April 2014

  • Update docs. All implemented functions are now included. bc4f031
  • First version of API documentation. cb3dec2
  • Change cursor appply method to support mongo driver 1.4.0. Refs #126 #105 a802934
  • Rename prototypes. 536743f

v0.11.0

1 April 2014

  • Update License to year range #128
  • Add support for cursor.rewind. Closes #131 #131
  • Add the cursor.size method 4de6a44
  • Add the cursor.map function a3e50ef
  • Update license date range 8ca0ec2
  • Add missing semicolon d1436ff

v0.10.1

4 March 2014

  • Extract lastErrorObject from the err argument if findAndModify fails #125

v0.10.0

15 January 2014

  • Updated README with lastErrorObject #117
  • Removed debug code #116
  • Normalize callback arguments. Same as shell. #114
  • Normalize lastErrorObject 014b5d1
  • Change normalized callback arguments. 1c1dbd5
  • Change the insert callback to make it more intuitive. 27ad374
  • lastErrorObject on all the write functions. 0f95a38
  • Add the lastErrorObject to the .save callback. Now the callbacks are as following. 873cf5d
  • Fix the remove callback parameters. a6a8f14
  • Add a remove statement to the insert test case. 6dd7b4e
  • Add missing error handling 6ff4158

v0.9.11

25 December 2013

  • Fix query included in database name #113

v0.9.10

16 December 2013

  • added toString for database and collection 80bc3eb

v0.9.9

10 December 2013

v0.9.8

22 November 2013

  • shrinkwrapping mongodb to 1.3.19. fixes #105 #105

v0.9.7

20 November 2013

  • Avoid getIndexes crash when called with no parameters. #101
  • index.js Emit ready event, when db connected #98
  • expose bson types visible in the shell using the shell names. fixes #99 #99

v0.9.6

22 September 2013

  • always closing in shutdown. see #93 d91831f

v0.9.5

18 September 2013

  • Manage the sutdown command. #93
  • Modified 'result' to 'res' to follow the example conventions used in the... #90
  • ObjectId example. Fixes #89 #89
  • minor style tweaks 172deed
  • Reordered examples 1d6475d
  • Modified 'result' to 'res' to follow the example conventions used in the rest of the document 7db0d89
  • Fixed long line eabccce

v0.9.4

11 September 2013

  • Refactor test insert code to use the db.col.insert() function #88
  • Add test for cursor explain + a minor change #85
  • Fix the link to the mongo native driver. #83
  • Refactor test insert code to use the db.col.insert() function. eaae470
  • Add test for cursor explain 128f30c
  • Delete unnecessary(and ugly) semicolon. 1083ba0
  • travis link updated 6d2a96e

v0.9.3

2 September 2013

v0.9.1

2 September 2013

  • Add test for chained collection names #82
  • avoiding another scrollbar in docs f65a1e8
  • moved repository to mafintosh 534580d
  • avoiding scrollbar in docs c0382ea

v0.9.0

31 August 2013

  • support for chained col names in col array. fixes #42 #42

v0.8.1

31 August 2013

v0.8.0

31 August 2013

  • Fix a couple of db.runCommand() issues #81
  • Add docs for runCommand() #80
  • Fix runCommand() bugs and update tests ba28316
  • moved license out of readme 93588ad
  • added .open and some comments 2ec9b9b
  • Fix runCommand() bugs. 66ae6a1
  • Update runCommand docs b35dd5a

v0.7.17

24 August 2013

  • Expose Database so the prototype can be easily extended #77
  • Fix getCollectionNames so result is the second arg of callback #76
  • Add support for db.getCollectionNames() and a test case for it. #73
  • Fix the mongojs module reference in test-crash.js #74
  • Add Cursor.explain() #69
  • Fixing problems with collections which have the same name as functions #67
  • Create Database function and add db methods to the prototype #65
  • Add support for runCommand #64
  • Add the justOne option to the remove method. #63
  • Add compatibility support for keyf in group command #48
  • Install mongodb refuses until the latest version does not specified directly #47
  • Expose Constructors #43
  • adding batchSize config to Cursor #31
  • updated default safe variable to false #28
  • Updating variable name to fix error #25
  • mongojs group command added. #26
  • Added an example to connection samples #12
  • 1 change in: README.md #11
  • Use non-native parser to parse _id #4
  • Exposing BSON constructors #1
  • return from remove if no docs are found - fixes #75 #75
  • reemitting error in nextTick. fixes #72 #72
  • Add support for both db.runCommand and db.collection.runCommand. Fixes #62. #62
  • Add the justOne option to the remove method and add tests for the remove method. fix #60 #60
  • Fixed #41 #41
  • 0.5.2 rc 67a77c9
  • first commit 061fff5
  • added npm test link 3de3b6f
  • better connection string support aec5e94
  • Use JS parser if native parser is not available 3c05202
  • better test coverage 20f7a5b
  • Refactor: add a Database constructor function and move db object functions to the prototype of said function. a37030a
  • fixed indentation e143b01
  • support for replication sets 54f4676
  • cursor is a 0.10 and 0.8 compat readable stream e20e689
  • exposed all methods from db and collection upwards e99d05a
  • using memolite 1d340be
  • removed normalize function as it serves no purpose with the new JS parser, some style tidy 6d55c1b
  • minor style normalizations 0af4f45
  • sync update and cursor chain tests e25e55c
  • test for streaming cursors e7326e9
  • Better docs f18e2a5
  • more examples in readme aeaa411
  • Add mongo native Db protptype methods to the Database prototype. 26d17aa
  • no more normalizing ids f703899
  • Added replication set to README c52dc8f
  • callback should be optional for all mutators 39c1080
  • docs for streaming cursors f68576f
  • added crash test 5db41d5
  • docs showing single function usage fcd1314
  • updated contributors 8d451fd
  • added proxy support 075c2cb
  • grouped public methods 5818a90
  • replSet config map deprecated but still supported 6bf676c
  • added section on tailable cursors 8995a19
  • added a ._apply method for the db as well 1bf49a3
  • compat with new stream interface 4881917
  • using thunky 3117fb3
  • compatible with mongodb 1.x.x df360a7
  • Add error handling to runCommand functions. f82d356
  • tidy b7c9350
  • Exposing BSON constructors. 6e8ffb3
  • style changes and now exporting a single function 652e088
  • collections is now optional 0afe687
  • mongodb group command added. 5b0b539
  • Missing comma in example 4deb11e
  • Add support for Cursor.explain() abb435e
  • added javascript type to examples 865d281
  • fixed requires d66171a
  • mongodb group command added. a534bc6
  • fixed normalize bug and removed a duplicate toArray method e87d993
  • Fix the code styling and add error handling. fd3b42f
  • Indentation fix in example. 4a9be9a
  • fixed auth issue f033377
  • added close function b03b6e1
  • safe option will now always be set if a callback is given to a collection dca0383
  • fixed cursor config issue 34819d8
  • more docs an supporting explicit docs 8eab6da
  • fixed test in regards to #76 and some formatting e839b01
  • updated homepage, description and keywords 8c21dc0
  • shorthand replSet config syntax fde6ad8
  • added destroy to cursor 9b50821
  • Fixing problems with collection names which have the same name as functions in native 3567157
  • license info c9c525c
  • updated monogdb version 11cb282
  • Added an example to the connections samples to show users that the ['collections'] array is optional on connect. f118ee8
  • tests should work even if not installed in node_modules 06efeee
  • Added getIndexes alias 55e8e63
  • fixed group issue 5ef53da
  • updated desc a6116dc
  • renamed close to disconnect d59f4eb
  • added git link to package.json 65cf8ae
  • fixed feature detection bug with Proxies d293b21
  • npm bump - stricter mongodb version 3555dde
  • we do not require native compilation now d419919
  • Remove duplicate .explain function. df3eef4
  • mongo shell is now mongo API 3b5755d
  • removed deprecated native_parser 2f8c908
  • added ian as a sympathy thing ed3875e
  • .remove returning 0 if something was removed 1191b51
  • exposed native mongodb object through a .client property 69ddb6f
  • using util.inherits 942cf51
  • adding batchSize config to Cursor 0f6cb6c
  • npm bump 8f54fc0
  • timeout is disabled in tailable example 75cef67
  • Another mongo docs link 8b0c428
  • bump 4ff7ea1
  • bump 74c3fd7
  • 0.7.13 - bump 3cec302
  • 0.6.0 - complete refactor 9afee11
  • bump d4e6513
  • bump 9835b78
  • Install mongodb refuses until the latest version does not specified directly. I don't know why. 34c45b3
  • change 1 word: to -> we 5fcb1f0
  • fixed typo a2bf06e
  • npm bump 3c1a871
  • bump b4e192f
  • changed tag line ac10c44
  • npm bump eaeadd9
  • bump 7deb303
  • bump version d51e56f
  • npm version bump bf22b83
  • npm version bump 70c06e1
  • better comment 1135bf0
  • 0.7.16 - bump cd0d397
  • git ignore 9a3810a
  • 0.7.14 - bump bbfca87
  • bump 112df62
  • added auto_connect = true ebf22e9
  • 0.7 release bb415cc
  • Added native compilation 6079f88
  • 0.7.12 - bump 9d26012
  • version bump 0939ff4
  • npm bump 8e28a91
  • better error message on bad conf 5b0099d
  • version bump dd81982
  • fixed possible null pointer 3a40661
  • removed redundant object aacfb51
  • fixed typo 20efefb
  • bump 2884029
  • npm bump bf89980
  • Updating the result.db variable to use the correct varible name for path. f599c3b
  • removed the sympathy thing 4ef10e3
  • 0.7.15 - bump 80e84fe
  • version bump 787ad7d
  • 0.7.11 - bump a2d4bfa
  • More typos. abf99f3
  • removed old comment b7872dc
  • collection should be collecitons in config 6e87f2f
  • fixed npm example eb89ed9
  • normalized the links 126220c
  • setting highWaterMark to 0 since the driver buffers f36fc8f