Class: Parse::Constraint::RelationQueryConstraint

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

Overview

Equivalent to the $relatedTo Parse query operation. If you want to retrieve objects that are members of a Relation field in your Parse class.

q.where :field.related_to => pointer

find all Users who have liked this post object

post = Post.first users = Parse::User.all :likes.related_to => post

Instance Method Summary collapse

Instance Method Details

#buildHash

Returns the compiled constraint.

Returns:

  • (Hash)

    the compiled constraint.



1672
1673
1674
1675
1676
1677
1678
# File 'lib/parse/query/constraints.rb', line 1672

def build
  # pointer = formatted_value
  # unless pointer.is_a?(Parse::Pointer)
  #   raise "Invalid Parse::Pointer passed to :related(#{@operation.operand}) constraint : #{pointer}"
  # end
  { :$relatedTo => { object: formatted_value, key: @operation.operand } }
end

#relRelationQueryConstraint

Alias for #related_to



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

constraint_keyword :$relatedTo

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

Examples:

q.where :field.related_to => pointer

Returns:



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