lib/parse/query.rb
def add_constraint(operator, value = nil, opts = {})
      @where ||= []
      constraint = operator # assume Parse::Constraint
      unless constraint.is_a?(Parse::Constraint)
        constraint = Parse::Constraint.create(operator, value)
      end
      return unless constraint.is_a?(Parse::Constraint)
      # to support select queries where you have to pass a `key` parameter for matching
      # different tables.
      if constraint.operand == :key || constraint.operand == "key"
        @key = constraint.value
        return
      end

      unless opts[:filter] == false
        constraint.operand = Query.format_field(constraint.operand)
      end
      @where.push constraint
      @results = nil
      self #chaining
    end
def add_constraint(operator, value = nil, opts = {})
      @where ||= []
      constraint = operator # assume Parse::Constraint
      unless constraint.is_a?(Parse::Constraint)
        constraint = Parse::Constraint.create(operator, value)
      end
      return unless constraint.is_a?(Parse::Constraint)
      # to support select queries where you have to pass a `key` parameter for matching
      # different tables.
      if constraint.operand == :key || constraint.operand == "key"
        @key = constraint.value
        return
      end

      unless opts[:filter] == false
        constraint.operand = Query.format_field(constraint.operand)
      end
      @where.push constraint
      @results = nil
      self #chaining
    end
def add_constraint ( operator , value = nil , opts = { } ) @where ||= [ ] constraint = operator # assume Parse::Constraint unless constraint . is_a? ( Parse :: Constraint ) constraint = Parse :: Constraint . create ( operator , value ) end return unless constraint . is_a? ( Parse :: Constraint ) # to support select queries where you have to pass a `key` parameter for matching # different tables. if constraint . operand == :key || constraint . operand == "key" @key = constraint . value return end unless opts [ :filter ] == false constraint . operand = Query . format_field ( constraint . operand ) end @where . push constraint @results = nil self #chaining end
Add a constraint to the query. This is mainly used internally for compiling constraints.
 @example
  # add where :field equals "value"
  query.add_constraint(:field.eq, "value")

  # add where :like_count is greater than 20
  query.add_constraint(:like_count.gt, 20)

  # same, but ignore field formatting
  query.add_constraint(:like_count.gt, 20, filter: false)

 @param operator [Parse::Operator] an operator object containing the operation and operand.
 @param value [Object] the value for the constraint.
 @param opts [Object] A set of options. Passing :filter with false, will skip field formatting.
 @see Query#format_field
 @return [self]
Add a constraint to the query . This is mainly used internally for compiling constraints . @example # add where : field equals value query . add_constraint ( : field . eq value )