Class: Parse::Constraint::NotContainedInConstraint

Inherits:
Parse::Constraint show all
Defined in:
lib/parse/query/constraints.rb

Overview

Equivalent to the ‘$nin` Parse query operation. Checks whether the value in the column field is not contained in the set of values in the target array. If the field is an array data type, it checks whether at least one value in the field array is not contained in the set of values in the target array.

q.where :field.not_in => array
q.where :player_name.not_in => ["Jonathan", "Dario", "Shawn"]

Instance Attribute Summary

Attributes inherited from Parse::Constraint

#operand, #operation, #operator, #value

Instance Method Summary collapse

Methods inherited from Parse::Constraint

#as_json, constraint_keyword, create, formatted_value, #formatted_value, #initialize, #key, #precedence, register, #to_s

Constructor Details

This class inherits a constructor from Parse::Constraint

Instance Method Details

#buildHash

Returns the compiled constraint.

Returns:

  • (Hash)

    the compiled constraint.



449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/parse/query/constraints.rb', line 449

def build
  val = formatted_value
  val = [val].compact unless val.is_a?(Array)

  # Convert Parse objects to pointers for array contains queries
  if val.is_a?(Array)
    val = val.map do |item|
      item.respond_to?(:pointer) ? item.pointer : item
    end
  end

  { @operation.operand => { key => val } }
end

#ninNotContainedInConstraint

Alias for #not_in



# File 'lib/parse/query/constraints.rb', line 430

#noneNotContainedInConstraint

Alias for #not_in Alias for #not_in - more readable when checking if array contains none of the values

Examples:

q.where :tags.none => ["rock", "pop"]  # has none of these tags

Returns:



442
# File 'lib/parse/query/constraints.rb', line 442

constraint_keyword :$nin

#not_contained_inNotContainedInConstraint

Alias for #not_in Alias for #not_in - more readable when checking if array contains none of the values

Examples:

q.where :tags.none => ["rock", "pop"]  # has none of these tags

Returns:



442
# File 'lib/parse/query/constraints.rb', line 442

constraint_keyword :$nin

#not_inNotContainedInConstraint

A registered method on a symbol to create the constraint. Maps to Parse operator “$nin”.

Examples:

q.where :field.not_in => array

Returns:



# File 'lib/parse/query/constraints.rb', line 424