Intro to Mongoid
Mongoid: object-document-mapper(ODM)
Mongoid Configuration:
rails g mongoid:config
Document:
Documents are the core objects in Mongoid ---- Mongoid::Document
Doucuments can be stored in a collection or embedded in other documents
Fields are attributes -- type String by default
class Movie include Mongoid::Document field :title, type: String end
Field Aliases:
field :birthName, as: :birth_name, type: String
store_in:
class Location include Mongoid::Document store_in collection: "Places" field :city, type: String end # Location gets stored in to "places" collection

浙公网安备 33010602011771号