Class: Parse::Constraint::CompoundQueryConstraint

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

Overview

Equivalent to the `$or` Parse query operation. This is useful if you want to find objects that match several queries. We overload the `|` operator in order to have a clean syntax for joining these `or` operations.

or_query = query1 | query2 | query3
query = Player.where(:wins.gt => 150) | Player.where(:wins.lt => 5)

query.or_where :field => value

Instance Attribute Summary

Attributes inherited from Parse::Constraint

#operand, #operation, #operator, #value

Instance Method Summary collapse

Methods inherited from Parse::Constraint

#as_json, contraint_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.


100
101
102
103
# File 'lib/parse/query/constraints.rb', line 100

def build
  or_clauses = formatted_value
  return { :$or => Array.wrap(or_clauses) }
end