Method: Mongoid::Criterion::Inclusion#in
- Defined in:
- lib/mongoid/criterion/inclusion.rb
#in(attributes = {}) ⇒ Object Also known as: any_in
Adds a criterion to the Criteria that specifies values where any can be matched in order to return results. This is similar to an SQL “IN” clause. The MongoDB conditional operator that will be used is “$in”.
Options:
attributes: A Hash where the key is the field name and the value is an Array of values that any can match.
Example:
criteria.in(:field => ["value1", "value2"])
criteria.in(:field1 => ["value1", "value2"], :field2 => ["value1"])
Returns: self
61 62 63 |
# File 'lib/mongoid/criterion/inclusion.rb', line 61 def in(attributes = {}) update_selector(attributes, "$in") end |