{
  "name": "mongolian",
  "description": "Mongolian DeadBeef is an awesome Mongo DB node.js driver",
  "version": "0.1.18",
  "homepage": "https://github.com/marcello3d/node-mongolian",
  "repository": {
    "type": "git",
    "url": "git://github.com/marcello3d/node-mongolian.git"
  },
  "author": {
    "name": "Marcello Bastéa-Forte",
    "email": "marcello@cellosoft.com",
    "url": "http://marcello.cellosoft.com/"
  },
  "main": "mongolian.js",
  "keywords": [
    "mongo",
    "mongodb",
    "database",
    "db",
    "nosql"
  ],
  "dependencies": {
    "buffalo": "0.1.3",
    "waiter": "0.1.1",
    "taxman": "0.1.1"
  },
  "devDependencies": {
    "nodeunit": "0.6.4"
  },
  "scripts": {
    "test": "node_modules/.bin/nodeunit test"
  },
  "engines": {
    "node": ">=0.4.0"
  },
  "readme": "Mongolian DeadBeef\n==================\nMongolian DeadBeef is an awesome Mongo DB node.js driver that attempts to closely approximate the [mongodb shell][1].\n\n[![Build Status](https://secure.travis-ci.org/marcello3d/node-mongolian.png)](http://travis-ci.org/marcello3d/node-mongolian)\n\nIntroduction\n------------\nMongolian DeadBeef and its documentation is super under construction! Go check out [examples/mongolian_trainer.js][2]\nand the rest of the source!\n\nUnlike other MongoDB node.js drivers, Mongolian DeadBeef is built from the ground up for node.js, using\n[node-buffalo][3] for BSON/message serialization.\n\nv0.1.15 Upgrade notes\n---------------------\n0.1.15 uses [node-buffalo][3] instead of mongodb-native for serialization, this means a few incompatibilities:\n\n+ The helper methods on `ObjectId` are removed, use the `ObjectId` constructor to parse hex strings\n+ `Code` type is removed, use vanilla function instances instead\n+ `DBRef` is not supported\n+ Error messages may be different\n\nInstallation\n------------\n**DISCLAIMER: The API is experimental (but stabilizing). I will be adding, removing, and changing the API in the\ninterest of a solid API. Use at your own risk**\n\nYou can either clone the source and install with `npm link`, or install the latest published version from npm with\n`npm install mongolian`.\n\nRunning Tests\n-------------\nRun the tests with `npm test`.\n\nMotivation\n----------\nNot a fan of existing asynchronous mongodb apis for node.js, I set out to write my own. To avoid completely reinventing\nthe wheel, much of the Mongolian DeadBeef API is inspired by the [mongodb shell][1].\n\nHigh level principles:\n\n* Less is more\n  * Nothing is added without careful consideration\n  * Remove everything but the essentials\n  * Each refactor should remove as much unnecessary lines of code as possible\n* Fail early and often\n  * If I can easily detect a programmer error, an exception will be thrown\n\nNotes:\n\n* mongodb is pretty simple, much of its functionality is defined as queries on special databases\n  * This allows for lots of code reuse\n* Avoid callbacks unless they are absolutely necessary\n\nBasics\n------\nMost of the work in MongolianDeadBeef doesn't occur until a query is actually made. This means that simple operations\nare fast and synchronous. Currently there is one connection per server.\n\nExamples\n--------\n\n    var Mongolian = require(\"mongolian\")\n\n    // Create a server instance with default host and port\n    var server = new Mongolian\n\n    // Get database\n    var db = server.db(\"awesome_blog\")\n\n    // Get some collections\n    var posts = db.collection(\"posts\")\n    var comments = db.collection(\"comments\")\n\n    // Insert some data\n    posts.insert({\n        pageId: \"hallo\",\n        title: \"Hallo\",\n        created: new Date,\n        body: \"Welcome to my new blog!\"\n    })\n\n    // Get a single document\n    posts.findOne({ pageId: \"hallo\" }, function(err, post) {\n        ...\n    })\n\n    // Document cursors\n    posts.find().limit(5).sort({ created: 1 }).toArray(function (err, array) {\n        // do something with the array\n    })\n    posts.find({ title: /^hal/ }).forEach(function (post) {\n        // do something with a single post\n    }, function(err) {\n        // handle errors/completion\n    })\n\nConnections and Authentication\n------------------------------\n    // Create a server with a specific host/port\n    var server = new Mongolian(\"mongo.example.com:12345\")\n\n\n    // Authenticate a database\n    db.auth(username, password)\n\n\n    // Supported connection url format: [mongo://][username:password@]hostname[:port][/databasename]\n    // Use uri-encoding for special characters in the username/password/database name\n\n    // Database/auth shorthand (equivalent to calling db() and auth() on the resulting server)\n    var db = new Mongolian(\"mongo://username:password@mongo.example.com:12345/database\")\n\n    // Connecting to replicasets:\n    var server = new Monglian(\n        \"server1.local\",\n        \"server2.local\",\n        \"server3.local:27018\"\n    )\n\nLogging\n-------\nBy default, Mongolian logs to console.log, but you can override this by specifying your own log object (any object that\nprovides `debug`, `info`, `warn`, and `error` methods):\n\n    var server = new Mongolian({\n        log: {\n            debug: function(message) { ... },\n            info: function(message) { ... },\n            warn: function(message) { ... },\n            error: function(message) { ... }\n        }\n    })\n\n    var server = new Mongolian('server1.local', 'server2.local', {\n        log: { ... }\n    })\n\nBSON Data Types\n---------------\nMongolian DeadBeef uses [node-buffalo][3]'s BSON serialization code. Most BSON types map directly to JavaScript types,\nhere are the ones that don't:\n\n    var Long =      require('mongolian').Long       // goog.math.Long - http://closure-library.googlecode.com/svn/docs/class_goog_math_Long.html\n    var ObjectId =  require('mongolian').ObjectId   // new ObjectId(byteBuffer or hexString)\n    var Timestamp = require('mongolian').Timestamp  // == Long\n    var DBRef =     require('mongolian').DBRef      // not supported yet\n\nGridFS\n------\nThe Mongo shell doesn't support gridfs, so Mongolian DeadBeef provides a custom Stream-based GridFS implementation.\nIt consists of two main classes, `MongolianGridFS` and `MongolianGridFile`. You can get a MongolianGridFS object from a\ndatabase with the `gridfs([gridfs name])` function.\n\n    // Get a GridFS from a database\n    var gridfs = db.gridfs() // name defaults to 'fs'\n\n    // Writing to GridFS consists of creating a GridFS file:\n    var file = gridfs.create({\n        filename:\"License\",\n        contentType:\"text/plain\"\n    })\n    // And getting writable Stream (see http://nodejs.org/docs/v0.4/api/streams.html#writable_Stream )\n    var stream = file.writeStream()\n\n    // You can then pipe a local file to that stream easily with:\n    fs.createReadStream('LICENSE').pipe(stream)\n\n    // Reading a file from GridFS is similar:\n    gridfs.findOne(\"License\", function (err, file) {\n        if (!err && file) {\n            // Get the read stream:\n            var stream = file.readStream()\n\n            // You could then pipe the file out to a http response, for example:\n            stream.pipe(httpResponse)\n        }\n    })\n\n    // You can access metadata fields from the file object:\n    file.length // might be a Long\n    file.chunkSize\n    file.md5\n    file.filename\n    file.contentType // mime-type\n    file.uploadDate\n    // These two are optional and may not be defined:\n    file.metadata\n    file.aliases\n\n    // If you make any changes, save them:\n    file.save()\n\nMongodb Shell Command Support\n-----------------------------\n\nNearly all commands are identical in syntax to the mongodb shell. However, asynchronous commands that go to the server\nwill have an _optional_ node.js style callback parameter.\n\nCurrently most commands starting with `get` are named without the `get`. Some of the getters are implemented as values\ninstead of functions.\n\n+ <strong>Bold functions</strong> are supported\n+ <strong><em>Italicized functions</em></strong> are supported with different syntax\n+ Everything else is currently unsupported\n\nThere will likely be methods below that are never supported by Mongolian DeadBeef, since I'm targetting a slightly\ndifferent use case.\n\n### Databases\nFrom http://api.mongodb.org/js/1.8.1/symbols/src/shell_db.js.html\n\n+ <code><strong>db.addUser</strong>(username, password[, readOnly=false][, callback])</code>\n+ <code><strong>db.auth</strong>(username, password)</code>\n+ <code>db.cloneDatabase(fromhost)</code>\n+ <code>db.commandHelp(name)</code> returns the help for the command\n+ <code>db.copyDatabase(fromdb, todb, fromhost)</code>\n+ <code>db.createCollection(name, { size : ..., capped : ..., max : ... } )</code>\n+ <code>db.currentOp()</code> displays the current operation in the db\n+ <code><strong>db.dropDatabase</strong>()</code> - see callback note below\n+ <code><strong>db.eval</strong>(func[, arg1, arg2, ...][, callback])</code> run code server-side - see callback note below\n+ <code><strong><em>db.getCollection</em></strong>(cname)</code> implemented as <code><strong>db.collection</strong>(cname)</code>\n+ <code><strong><em>db.getCollectionNames</em></strong>()</code> implemented as <code><strong>db.collectionNames</strong>(callback)</code>\n+ <code>db.getLastError()</code> - just returns the err msg string\n+ <code><strong><em>db.getLastErrorObj</em></strong>()</code> implemented as <code><strong>db.lastError</strong>(callback)</code> - return full status object\n+ <code><strong><em>db.getMongo</em></strong>()</code> get the server connection object implemented as <code><strong>db.server</strong></code>\n+ <code>db.getMongo().setSlaveOk()</code> allow this connection to read from the nonmaster member of a replica pair\n+ <code><strong><em>db.getName</em></strong>()</code> implemented as <code><strong>db.name</strong></code>\n+ <code>db.getPrevError()</code> _(deprecated?)_\n+ <code>db.getProfilingStatus()</code> - returns if profiling is on and slow threshold\n+ <code>db.getReplicationInfo()</code>\n+ <code>db.getSiblingDB(name)</code> get the db at the same server as this one\n+ <code>db.isMaster()</code> check replica primary status\n+ <code>db.killOp(opid)</code> kills the current operation in the db\n+ <code>db.listCommands()</code> lists all the db commands\n+ <code>db.printCollectionStats()</code>\n+ <code>db.printReplicationInfo()</code>\n+ <code>db.printSlaveReplicationInfo()</code>\n+ <code>db.printShardingStatus()</code>\n+ <code><strong>db.removeUser</strong>(username[, callback])</code> - see callback note below\n+ <code>db.repairDatabase()</code>\n+ <code>db.resetError()</code>\n+ <code><strong>db.runCommand</strong>(cmdObj[, callback])</code> run a database command. if cmdObj is a string, turns it into { cmdObj : 1 }\n+ <code>db.serverStatus()</code>\n+ <code>db.setProfilingLevel(level,<slowms>)</code> 0=off 1=slow 2=all\n+ <code>db.shutdownServer()</code>\n+ <code>db.stats()</code>\n+ <code>db.version()</code> current version of the server\n\n### Collections\nFrom http://api.mongodb.org/js/1.8.1/symbols/src/shell_collection.js.html\n\n+ <code>collection.find().help()</code> - show DBCursor help\n+ <code><strong>collection.count</strong>(callback)</code>\n+ <code>collection.dataSize()</code>\n+ <code><strong>collection.distinct</strong>(key[, query], callback)</code> - eg. collection.distinct( 'x' )</code>\n+ <code><strong>collection.drop</strong>([callback])</code> drop the collection - see callback note below\n+ <code><strong>collection.dropIndex</strong>(name[, callback])</code> - see callback note below\n+ <code>collection.dropIndexes()</code>\n+ <code><strong>collection.ensureIndex</strong>(keypattern[,options][, callback])</code> - options is an object with these possible fields: name, unique, dropDups - see callback note below\n+ <code>collection.reIndex()</code>\n+ <code><strong>collection.find</strong>([query],[fields])</code> - query is an optional query filter. fields is optional set of fields to return.\n                                          e.g. <code>collection.find( {x:77} , {name:1, x:1} )</code> - returns a cursor object\n+ <code><strong>collection.find(...).count</strong>()</code>\n+ <code><strong>collection.find(...).limit</strong>(n)</code>\n+ <code><strong>collection.find(...).skip</strong>(n)</code>\n+ <code><strong>collection.find(...).sort</strong>(...)</code>\n+ <code><strong>collection.findOne</strong>([query][callback])</code>\n+ <code><strong>collection.findAndModify</strong>( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )</code>\n  ex: finds document with comment value 0, increase its 'count' field by 1, and return the updated document.\n  <code>collection.findAndModify( {query: {comment:'0'}, update : {\"$inc\":{\"count\":1}}, 'new': true}, function (err, doc) {\n  console.log(doc)\n})</code>\n+ <code><strong><em>collection.getDB</em></strong>()</code> get DB object associated with collection implemented as <code><strong>collection.db</strong></code>\n+ <code><strong><em>collection.getIndexes</em></strong>()</code> implemented as <code><strong>collection.indexes</strong>(callback)</code>\n+ <code>collection.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )</code>\n+ <code><strong>collection.mapReduce</strong>( mapFunction , reduceFunction , [optional params][, callback])</code>\n+ <code><strong>collection.remove</strong>(query[, callback])</code> - see callback note below\n+ <code>collection.renameCollection( newName , [dropTarget] )</code> renames the collection.\n+ <code><strong>collection.runCommand</strong>( name , [options][, callback])</code> runs a db command with the given name where the first param is the collection name\n+ <code><strong>collection.save</strong>(obj[, callback])</code> - see callback note below\n+ <code>collection.stats()</code>\n+ <code>collection.storageSize()</code> - includes free space allocated to this collection\n+ <code>collection.totalIndexSize()</code> - size in bytes of all the indexes\n+ <code>collection.totalSize()</code> - storage allocated for all data and indexes\n+ <code><strong>collection.update</strong>(query, object[, upsert\\_bool, multi\\_bool][, callback])</code> - see callback note below\n+ <code>collection.validate()</code> - SLOW\n+ <code>collection.getShardVersion()</code> - only for use with sharding\n\n### Cursors\nFrom http://api.mongodb.org/js/1.8.1/symbols/src/shell_query.js.html\n\n+ <code><strong>cursor.sort</strong>( {...} )</code>\n+ <code><strong>cursor.limit</strong>( n )</code>\n+ <code><strong>cursor.skip</strong>( n )</code>\n+ <code><strong>cursor.count</strong>()</code> - total # of objects matching query, ignores skip,limit\n+ <code><strong>cursor.size</strong>()</code> - total # of objects cursor would return, honors skip,limit\n+ <code><strong>cursor.explain</strong>([verbose])</code>\n+ <code><strong>cursor.hint</strong>(...)</code>\n+ <code>cursor.showDiskLoc()</code> - adds a $diskLoc field to each returned object\n+ <code><strong>cursor.toArray</strong>(callback)</code> - unique to Mongolian DeadBeef\n+ <code><strong>cursor.forEach</strong>(func, callback)</code> - calls func for each document, and callback upon completion or error\n+ <code>cursor.print()</code> - output to console in full pretty format\n+ <code><strong>cursor.map</strong>( func )</code> - map documents before they're returned in next, toArray, forEach\n+ <code>cursor.hasNext()</code>\n+ <code><strong>cursor.next</strong>([callback])</code> - returns the next document or null if there are no more\n\n\n### Callbacks\nCallbacks take the standard node.js format: `function(error, value)`\n\nMongodb handles write operations (insert, update, save, drop, etc.) asynchronously. If you pass a callback into one of\nthese methods, this is equivalent to immediately calling `db.lastError(callback)` on the same server/connection. Passing\na null value will not send a getLastError command to the server.\n\nCurrently there is no way to specify the write concern on these inlined callbacks.\n\nTodo\n----\n\n* Connection pooling\n* Various utility methods\n* More unit tests\n* Documentation\n* Cleanup\n\nContributing\n------------\nTry it out and send me feedback! That's the best help I could use right now. Unit tests are good, too.\n\nLicense\n-------\nMongolian DeadBeef is open source software under the [zlib license][4].\n\n[1]: http://www.mongodb.org/display/DOCS/dbshell+Reference\n[2]: https://github.com/marcello3d/node-mongolian/blob/master/examples/mongolian_trainer.js\n[3]: https://github.com/marcello3d/node-buffalo\n[4]: https://github.com/marcello3d/node-mongolian/blob/master/LICENSE\n",
  "_id": "mongolian@0.1.18",
  "_from": "mongolian"
}
