Object Mappers for Ruby and MongoDB

Although it's possible to use the Ruby driver by itself, sometimes you want validations, associations, and many of the other conveniences provided by ActiveRecord. Here, then, is a list of the most popular object mappers available for working with Ruby and MongoDB.

Recommendations

First we advise that you get to know how the database itself works. This is best accomplished by playing with the shell and experimenting with the Ruby driver (or any of the other drivers, for that matter)*.

Once you understand how MongoDB works, you'll be in a good position to choose the object mapper that best suits your needs. So long as you pick an OM that's used in production and is actively developed, you really can't make a bad choice.

Libraries

MongoMapper

John Nunemaker's OM. Used in production and actively-developed. ActiveModel support forthcoming.

Installation:

  • gem install mongo_mapper

Source:

Documentation:

Articles:

Mongoid

If you're using Mongoid, please read the Using Mongoid page on this site.

Durran Jordan's OM. Used in production and actively-developed. Supports ActiveModel and Rails 3.

Installation:

  • gem install mongoid

Source:

Documentation:

Mongomatic

A simple object mapper emphasizing MongoDB idioms.

Installation:

  • gem install mongomatic

Source:

MongoDoc

MongoDoc is a simple, fast ODM for MongoDB. The project will eventually be merged into Mongoid.

Installation:

  • gem install mongodoc

Source:

MongoModel

Sam Pohlenz's OM. Actively-developed.

Notes:

An OM with emphaisis on ActiveModel compatibility.

Installation:

  • gem install mongomodel

Source:

Candy

Stephen Eley's OM. Actively-developed.

Notes:

From the README:
Candy's goal is to provide the simplest possible object persistence for the MongoDB database. By "simple" we mean "nearly invisible." Candy doesn't try to mirror ActiveRecord or DataMapper. Instead, we play to MongoDB's unusual strengths – extremely fast writes and a set of field-specific update operators – and do away with the cumbersome, unnecessary methods of last-generation workflows.

Installation:

  • gem install candy

Source:

MongoRecord

10gen's original OM.

Notes:
MongoRecord is an ActiveRecord-like OM, and the first of its kind developed for MongoDB. Favored by a contingent of developers for its simplicity, MongoRecord currently receives a lot of love from Nate Wiger.

Installation:

  • gem install mongo_record

Source:


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.

blog comments powered by Disqus