Module: MongoDoc::Finders
- Defined in:
- lib/mongodoc/finders.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#find(*args) ⇒ Object
Find a
Document
based on id (String
orMongo::ObjectID
). -
#find_all ⇒ Object
Find all Documents in the collections.
-
#find_one(conditions_or_id) ⇒ Object
Find a
Document
based on id (String
orMongo::ObjectID
) or conditions.
Class Method Details
Instance Method Details
#find(*args) ⇒ Object
Find a Document
based on id (String
or Mongo::ObjectID
)
Person.find('1')
Person.find(obj_id_1, obj_id_2)
24 25 26 |
# File 'lib/mongodoc/finders.rb', line 24 def find(*args) criteria.id(*args) end |
#find_all ⇒ Object
Find all Documents in the collections
Person.find_all
31 32 33 |
# File 'lib/mongodoc/finders.rb', line 31 def find_all criteria end |
#find_one(conditions_or_id) ⇒ Object
Find a Document
based on id (String
or Mongo::ObjectID
) or conditions
Person.find_one('1')
Person.find_one(:where => {:age.gt > 25})
40 41 42 43 44 45 46 |
# File 'lib/mongodoc/finders.rb', line 40 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 |