I have a custom Parse class...
Follow
-----------------
Follower - PFUser
Followee - PFUser
I've also added a custom field fullName
to the User table.
This can't change. (It can be added to though)
I've done several queries using it and I'm stumbling on this last one.
I'd like to be able to run a query that returns Users whose fullName
contains some given text but only users who are following the current user.
i.e.
If Paul
and Peter
are following me there will be Follow objects where I am the followee and they are the follower. Also, Phillip
is not following me so there is no Follow record for him.
If I run this query with the search text @"P"
then it should return Peter and Paul and not Phillip.
I just can't work out how to create the query.
I have tried something like this...
PFQuery *followQuery = [CCFollow query];
[followQuery whereKey:@"followee" equalTo:[PFUser currentUser]];
PFQuery *nameQuery = [PFUser query];
[nameQuery whereKey:@"fullName" contains:searchText];
[nameQuery whereKey:@"objectId" equalsKey:@"follower" inQuery:followQuery];
But it returns no error and no objects.
[nameQuery whereKey:@"objectId" equalsKey:@"follower" inQuery:followQuery];
This line of code is not correct. Here, the key objectId is of type string and followers is of type PFUser. You could create an extra column "followerString" which stores the objectId of the follower in string format so that you can compare.