通过连接表解析查找

时间:2014-10-13 14:16:37

标签: ios objective-c parse-platform

我正在使用Parse并拥有以下实体..

User
----
fullName

Follow
----
follower (User)
followee (User)

我想按照以下标准对Users进行查找。

  1. 鉴于某些文字,其名称包含该文字。
  2. 存在Follow记录,其中follower,当前用户为followee
  3. 我目前正在尝试这样的事情......

    PFQuery *followQuery = [Follow query];
    [followQuery whereKey:@"followee" equalTo:[PFUser currentUser]];
    
    PFQuery *userQuery = [PFUser query];
    [userQuery whereKey:@"fullName" containsString:theSearchText];
    
    [userQuery whereKey:@"somethingHereButNotSureWhat" matchesQuery:followQuery];
    

    有没有办法让我的工作让我失踪?我似乎无法让查询工作在我放入密钥的任何地方。我需要放self.或其他东西,但我尝试过的东西都没有。

2 个答案:

答案 0 :(得分:1)

如何在matchesQuery课程上使用Follow

PFQuery *userQuery = [PFUser query];
[userQuery whereKey:@"fullName" containsString:@"SEARCHTEXTHERE"];

PFQuery *followQuery = [PFQuery queryWithClassName:@"Follow"];
[followQuery whereKey:@"followee" equalTo:[PFUser currentUser]];
[followQuery whereKey:@"follow" matchesQuery:userQuery];

答案 1 :(得分:0)

我认为这样的事情会起作用:

PFQuery *followQuery = [PFQuery queryWithClassName:@"Follow"];
[followQuery whereKey:@"followee" equalTo:[PFUser currentUser]];

PFQuery *userQuery = [PFQuery queryWithClassName:@"_User"];
[userQuery whereKey:@"fullName" containsString:@"SEARCHTEXTHERE"];
[userQuery whereKey:@"USERKEYHERE" matchesKey:followQuery inQuery:followQuery];

希望这有帮助!