Method: Mongoid::Criteria::Queryable::Selectable#nin
- Defined in:
- lib/mongoid/criteria/queryable/selectable.rb
#nin(condition) ⇒ Selectable Also known as: not_in
Adds the $nin selection to the selectable.
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'lib/mongoid/criteria/queryable/selectable.rb', line 494 def nin(condition) if condition.nil? raise Errors::CriteriaArgumentRequired, :nin end condition = (condition) if strategy send(strategy, condition, "$nin") else condition.inject(clone) do |query, (field, value)| v = {'$nin' => value} if negating? v = {'$not' => v} end query.add_field_expression(field.to_s, v) end.reset_strategies! end end |