在Parse中使用指针获取关系数据

5 parse-platform

我们在从关系表中读取数据时遇到了问题.我们有table1,它的一列中有一个指向另一个表的指针,称为table2.我们需要在一个查询请求中从table1的指针获取table2中的数据.

所以,现在的查询是:

PFQuery *query = [PFQuery queryWithClassName:@"table1"];
[query whereKey:@"completed"  equalTo:[NSNumber numberWithBool:NO]];
[query whereKey:@"userId" equalTo:[PFObject objectWithoutDataWithClassName:@"Users" objectId:@"someID"]];

[query  findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)
 {
     if (!error)
     {

         //new user
         if(objects.count==0)
         {

         }

         else
         {
           //here we get "Users:vAJS2T96V1" ,which is the pointer to table2 ,but we need to go deeper to the other table 
           // in the same query, and get the data from table2 .
         }
     }

 }];
Run Code Online (Sandbox Code Playgroud)

我们如何在一个查询中从table2获取数据?

Mar*_*dal 3

您使用“includeKey”从另一个表中获取数据:

[query includeKey:@"Users"];
Run Code Online (Sandbox Code Playgroud)

更多信息:http://blog.parse.com/2011/12/06/queries-for-relational-data/