Class: Parse::Constraint::ContainedByConstraint
- Inherits:
-
Parse::Constraint
- Object
- Parse::Constraint
- Parse::Constraint::ContainedByConstraint
- 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 Attribute Summary
Attributes inherited from Parse::Constraint
#operand, #operation, #operator, #value
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint.
-
#contained_by ⇒ ContainedByConstraint
A registered method on a symbol to create the constraint.
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
#build ⇒ Hash
Returns 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_by ⇒ ContainedByConstraint
A registered method on a symbol to create the constraint. Maps to Parse operator "$containedBy".
520 |
# File 'lib/parse/query/constraints.rb', line 520 constraint_keyword :$containedBy |