Module: MongoDoc::Finders
- Defined in:
- lib/mongo_doc/finders.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#find(*args) ⇒ Object
Find a
Document
based on id (String
orBSON::ObjectID
). -
#find_all ⇒ Object
Find all Documents in the collections.
-
#find_one(conditions_or_id) ⇒ Object
Find a
Document
based on id (String
orBSON::ObjectID
) or conditions.
Class Method Details
Instance Method Details
#find(*args) ⇒ Object
Find a Document
based on id (String
or BSON::ObjectID
)
Person.find('1')
Person.find(obj_id_1, obj_id_2)
13 14 15 |
# File 'lib/mongo_doc/finders.rb', line 13 def find(*args) criteria.id(*args) end |
#find_all ⇒ Object
Find all Documents in the collections
Person.find_all
20 21 22 |
# File 'lib/mongo_doc/finders.rb', line 20 def find_all criteria end |
#find_one(conditions_or_id) ⇒ Object
Find a Document
based on id (String
or BSON::ObjectID
) or conditions
Person.find_one('1')
Person.find_one(:where => {:age.gt > 25})
29 30 31 32 33 34 35 |
# File 'lib/mongo_doc/finders.rb', line 29 def find_one(conditions_or_id) if Hash === conditions_or_id Mongoid::Criteria.translate(self, conditions_or_id).one else Mongoid::Criteria.translate(self, conditions_or_id) end end |