You can use whereKey:equalTo:
on a relation column and pass it a PFObject
. This query will then return all Teacher
objects which have this student
in their "students"
relation:
PFQuery *query = [PFQuery queryWithClassName:@"Teacher"];
[query whereKey:@"students" equalTo:student];
In this example, the student
is a PFObject
with a className that matches the relation in "students"
. If this is a relation of PFUser
s and you're looking for the current user's "Teacher"
s, you'd use:
PFQuery *query = [PFQuery queryWithClassName:@"Teacher"];
[query whereKey:@"students" equalTo:[PFUser currentUser]];
This answer also posted on Parse's community forums: https://parse.com/questions/how-do-i-query-using-pfrelation-when-i-just-have-pfuser