MongoDB Support for Pronto
Pronto.js is a toolkit for building component-based evented systems in Node.js. Using the design pattern commonly called the Chain of Command, sequences of tasks are tied together and executed.
This project provides commands (individual components) for working with MongoDB.
Here is an example of adding a series of MongoDB operations to a
mongo = ;register// Open a connection to a MongoDB.// Get (or create) a collection called 'narf'.// Insert a document into the collection.// Add another document (using save, which is insert-or-update).// Find a single document that matches the specified filter.// Normally, we would do something useful here.... but we're not going to.// Drop the entire 'narf' collection.// Close the database.;
The above shows how Pronto-MongoDB commands can be used within a Pronto application. The example is simple, but most of the commands have many available parameters, allowing you to construct elaborate applications.
Q: How do you decide which Mongo features to implement as commands?
A: Those that seem practical (to me) tend to get implemented. If you find a feature of MongoDB that you think should be implemented as a command, please file an issue. I'm happy to build out commands as they are useful.
Sometimes, though, it makes more sense to perform some MongoDB operations within a command. Manipulating cursors often fall into this category. It makes more sense (in most cases) to treat a cursor as a piece of data inside of a command rather than a command of some sort.
This module is built on the
mongodb) driver library, which provides an excellent evented interface.
This module was sponsored by ConsumerSearch.com, part of the About.Com network, a New York Times company.