Class: Parse::Constraint::NotContainedInConstraint

Inherits:
Constraint
  • Object
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 Method Summary collapse

Instance Method Details

#build ⇒ Hash

Returns the compiled constraint.

Returns:

  • (Hash) —

    the compiled constraint.



1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
# File 'lib/parse/query/constraints.rb', line 1188

def build
  val = list_value

  # 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

#nin ⇒ NotContainedInConstraint

Alias for #not_in



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

#none ⇒ NotContainedInConstraint

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:



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

constraint_keyword :$nin

#not_contained_in ⇒ NotContainedInConstraint

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:



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

constraint_keyword :$nin

#not_in ⇒ NotContainedInConstraint

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 1163