Module: Mongoid::Contexts::Ids
- Included in:
- Enumerable, Mongo
- Defined in:
- lib/mongoid/contexts/ids.rb
Instance Method Summary collapse
-
#id_criteria(params) ⇒ Object
Return documents based on an id search.
Instance Method Details
#id_criteria(params) ⇒ Object
Return documents based on an id search. Will handle if a single id has been passed or mulitple ids.
Example:
context.id_criteria([1, 2, 3])
Returns:
The single or multiple documents.
15 16 17 18 19 20 21 22 |
# File 'lib/mongoid/contexts/ids.rb', line 15 def id_criteria(params) criteria.id(params) result = params.is_a?(Array) ? criteria.entries : one if Mongoid.raise_not_found_error raise Errors::DocumentNotFound.new(klass, params) if result.blank? end return result end |