9. What is ? Think of ActiveRecord for MongoDB Mapping Ruby objects to MongoDB documents and embedded documents Supports Rails3 Named scopes, rich criteria API Also some problems…
10. How to use ? class Building include Mongoid::Document include Mongoid::Timestamps embeds_many :floors field :name field :occupied, :type => Boolean, :default => false field :area, :type => Integer end
11. How to use ? class Level include Mongoid::Document embedded_in :building, :inverse_of => :levels embeds_many :rooms field :type validate :type, :presence => true, :uniqueness => {:scope => :city} end
12. Building.first(:conditions => {:name.in => [“Dom”,”Stodoła”]}) Building.levels.where(:type => “poddasze”) Building.find(:all, :conditions => {:area.gt => 100}) How to use ?
13. Callbacks: after_save, before_save, before_validation, after_create, etc. Inheritance: class House < Building end house = House.new; house._type # => “house” Building.all# [house] How to use ?