Please enable JavaScript.
Coggle requires JavaScript to display documents.
MongoID Rails (Class (Customize (initialize, mongoize: create DB from…
MongoID Rails
Class
include Mongoid::Document
include Mongoid::Timestamps
geolocation
Customize
initialize
mongoize: create DB from object
demongoize: create object from DB
envolve: convert object to DB form
Find
find_by
find_or_create_by
find_or_initialize_by (not persist)
find
Relationship
embedded
embeds_one (1-1)
embedded_in
polymorphic
embeds_many (1-M)
linked
belongs_to (M-1)
has_many
foreign_key
has_one (1-1)
has_and_belongs_to_many (M-M)
Constraints
Validation: use ActiveModel (ex: validates_presence_of, ...)
Dependent
destroy (running callback)
delete
nullify
restrict
Queries
Where
count
distinct
exists
geolocation
first_or_create_by
first_or_initilize_by
compare number: gt / lt
compare string: $regex
pluck (select field not null)
Scope
scope
default_scope
unscoped
in (union)
or