Method: Mongoid::Criterion::Exclusion#not_in
- Defined in:
- lib/mongoid/criterion/exclusion.rb
#not_in(exclusions) ⇒ Object
Adds a criterion to the Criteria that specifies values where none should match in order to return results. This is similar to an SQL “NOT IN” clause. The MongoDB conditional operator that will be used is “$nin”.
Options:
exclusions: A Hash where the key is the field name and the value is an Array of values that none can match.
Example:
criteria.not_in(:field => ["value1", "value2"])
criteria.not_in(:field1 => ["value1", "value2"], :field2 => ["value1"])
Returns: self
43 44 45 |
# File 'lib/mongoid/criterion/exclusion.rb', line 43 def not_in(exclusions) exclusions.each { |key, value| @selector[key] = { "$nin" => value } }; self end |