Ruby MongoDB Driver

The MongoDB Ruby driver is the officially supported Ruby driver for MongoDB. It is written in pure Ruby and is optimized for simplicity. It can be used on its own, but it also serves as the basis of several object mapping libraries.

Get Started

To get started with the Ruby driver, see Installation and Quick Start.

BSON

The Ruby BSON implementation is packaged in a separate gem with C and Java extensions for speed depending on the runtime enviroment.

For reference on the Ruby BSON gem, see BSON.

Object Mappers

Because MongoDB is so easy to use, the basic Ruby driver can be the best solution for many applications. But if you need validations, associations, and other high-level data modeling functions, then you may need Object Document Mapper.

In the context of a Rails application, an Object Document Mapper provides functionality equivalent to, but distinct from, ActiveRecord. Because MongoDB is a document-based database, these mappers are called Object Document Mappers (ODM) as opposed to Object Relational Mappers (ORM).

The ODM officially supported by MongoDB is Mongoid, originally written by Durran Jordan.

For tutorials on Mongoid, see Mongoid.

Installation  →