Mongoid (pronounced mann-goyd) is an Object-Document-Mapper (ODM) for MongoDB written in Ruby. It was conceived in August, 2009 during a whiskey-induced evening at the infamous Oasis in Florida, USA by Durran Jordan.
The philosophy of Mongoid is to provide a familiar API to Ruby developers who have been using Active Record or Data Mapper, while leveraging the power of MongoDB's schemaless and performant document-based design, dynamic queries, and atomic modifier operations.
This is the site for Mongoid 3 documentation, along with Origin and Moped. If you want the Mongoid 2 docs, please go here.
|Mongoid only supports MRI 1.9.3, and HEAD, and JRuby 1.6.0+ in 1.9 mode. All code samples will use 1.9 syntax.|
class Artist include Mongoid::Document field :name, type: String embeds_many :instruments end class Instrument include Mongoid::Document field :name, type: String embedded_in :artist end syd = Artist.where(name: "Syd Vicious").between(age: 18..25).first syd.instruments.create(name: "Bass") syd.with(database: "bands", session: "backup").save!