tdegrunt edited this page Sep 14, 2010 · 3 revisions
Clone this wiki locally


MongoDb is a fast document based database. It doesn’t have a REST interface by default, though that can be enabled. MongoDbRest provides a full REST interface, which also conforms to the REST specification. MongoDbRest is written for node.js and is very fast, without concurrency I’ve been able to retrieve a singe document over 800 times a second.

Getting Started

Once, you’ve downloaded and installed MongoDb & node.js you’re pretty much setup to use MongoDbRest.
You would need a database & collection to work with of course. You can create those using the mongo command line utility.

MongoDb shell version: 1.4.2
> use tasks // creates a database tasks if it doesn’t already exist
switched to db tasks
> show collections // shows that there aren’t any collections
> db.tasks.insert({"description": “test”, “isDone”: false}) // Inserts a task in the tasks collection of the tasks database.

Repeat the last command a few times, with different descriptions. Once this is done, you have some data to actually start querying, updating and/or deleting.

Using with SproutCore

MongoDbRest makes it very simple to use MongoDb with SproutCore and make an ideal combination.
If you follow the Todos tutorial of SproutCore, the ‘setting up the backend’ part is only setting up a database and collection for use (see Getting Started above). Then instead of using the regular DataSource use the one provided in this Gist.