Working with version 1.0.0, eWEEK Labs took a comprehensive look at the main features that make up the MongoDB driver for Node.js, including available database features, the driver API, and overall performance based on how fast the calls were made.
I tested the MongoDB driver on a Rackspace Ubuntu 11.04 server, running Node.js with the Express framework. For timing, I used the node-microtime module. For source-code editing, I used the Cloud9 integrated development environment (IDE), but to run the applications, I used the bash shell directly.
As with most Node modules, installation was quick and smooth with the Node Package Manager (NPM) installer. I chose to install the packages globally using the g option of NPM. After creating the initial express project, I linked the package to the project with the NPM link command.
The code makes heavy use of the Node.js approach of asynchronous callback functions so that the code does not block while the database operations are performing. I opened the database and passed in a function that gets called after the database is opened. Thats the first callback and is also where I retrieve the collection.
This callback approach can be a little confusing to less-experienced coders. The idea is that Node.js is fully asynchronous and nonblocking; as such, I passed in a function that gets called only after the database is open. Meanwhile, the rest of the other function continues on its way, and depending on how long the I/O takes, likely finishes before the database operations are even complete. This is the norm for Node.js programming and is the approach upon which the entire library is built.
Typically, MongoDB programming, standard database operations (create, insert, update and delete) run on a collection object. IT developers who have used a MongoDB driver in another language (such as C# or Ruby) should have no trouble applying these same operations using the Node.js driver