Introduction

Installation

WARNING! The API is super experimental, and will be adding, removing, and changing the API regularly. Use at your own
risk

You can either clone the source and install with npm link, or install the latest published version from npm with
npm install mongolian.

Running Tests

Run the tests with npm test.

Motivation

Not a fan of existing asynchronous mongodb apis for node.js, I set out to write my own. To avoid completely reinventing
the wheel, much of the Mongolian DeadBeef API is inspired by the mongodb shell.

High level principles:

Less is more

Nothing is added without careful consideration

Remove everything but the essentials

Each refactor should remove as much unnecessary lines of code as possible

Fail early and often

If I can easily detect a programmer error, an exception will be thrown

Notes:

mongodb is pretty simple, much of its functionality is defined as queries on special databases

This allows for lots of code reuse

Avoid callbacks unless they are absolutely necessary

Basics

Most of the work in MongolianDeadBeef doesn't occur until a query is actually made. This means that simple operations
are fast and synchronous. Currently there is one connection per server. You can have multiple queries simultaneously on
a single mongodb connection, so I'm not sure how important pooling is at this point.

cursor.forEach(func, callback) - calls func for each element, and callback upon completion or error

cursor.print() - output to console in full pretty format

cursor.map( func )

cursor.hasNext()

cursor.next([callback]) - executes callback(null) if there are no more elements

Callbacks

Callbacks take the standard node.js format: function(error, value)

Mongodb handles write operations (insert, update, save, drop, etc.) asynchronously. If you pass a callback into one of
these methods, this is equivalent to immediately calling db.lastError(callback) on the same server/connection. Passing
a null value will not send a getLastError command to the server.

Currently there is no way to specify the write concern on these inlined callbacks.

Todo

Various utility methods

More unit tests

Documentation

Connection pooling

Cleanup

Contributing

Try it out and send me feedback! That's the best help I could use right now. Unit tests are good, too.