Class: Parse::Constraint::ContainedByConstraint

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

Overview

Equivalent to the $containedBy Parse query operation. Matches documents where the array field's values are all within the supplied set (the inverse of ContainsAllConstraint: the field must be a subset of the provided array). The field column should be of type Array in your Parse class.

q.where :field.contained_by => [1, 2, 3] q.where :tags.contained_by => ["ruby", "rails", "parse"]

Instance Method Summary collapse

Instance Method Details

#buildHash

Returns the compiled constraint.

Returns:

  • (Hash)

    the compiled constraint.



524
525
526
527
528
# File 'lib/parse/query/constraints.rb', line 524

def build
  val = formatted_value
  val = [val].compact unless val.is_a?(Array)
  { @operation.operand => { key => val } }
end

#contained_byContainedByConstraint

A registered method on a symbol to create the constraint. Maps to Parse operator "$containedBy".

Examples:

q.where :tags.contained_by => ["ruby", "rails"]

Returns:



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

constraint_keyword :$containedBy