我正在尝试查询confessions
不是author
的{{1}}班级的所有记录...但只查看我们的[PFUser currentUser]
没有评分的所有记录[PFUser currentUser]
上课。
ratings
上课:
confessions
课程:
基本上,我想将这两个查询连接成一个(不知何故):
ratings
如果没有简单的方法来达到我想要的目标,你认为我应该改变模型吗?我应该只是获取所有评分,然后以某种方式忽略所有等于// get all confessions from other users
PFQuery *qConfessions = [PFQuery queryWithClassName:@"confessions"];
[qConfessions whereKey:@"author" notEqualTo:[PFUser currentUser]];
// get all ratings from this user
PFQuery *qRatings = [PFQuery queryWithClassName:@"ratings"];
[qRatings whereKey:@"ratedBy" equalTo:[PFUser currentUser]];
// get all qConfessions that are not in qRatings.confession
// YOUR HELP HERE :)
的{{1}}?欢迎任何帮助。谢谢。
答案 0 :(得分:0)
试试这个:
// get all qConfessions that are not in qRatings.confession
[qRatings whereKey:@"confession" doesNotMatchQuery: qConfessions];
[qRatings findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error == nil) {
} esle {
}
}];
答案 1 :(得分:0)
我已经通过在Parse上向confessionId
类添加ratings
字段并使用以下代码来解决方法:
// get all ratings from this user
PFQuery *qRatings = [PFQuery queryWithClassName:@"ratings"];
[qRatings whereKey:@"ratedBy" equalTo:[PFUser currentUser]];
// get all confessions from other users
PFQuery *qConfessions = [PFQuery queryWithClassName:@"confessions"];
[qConfessions whereKey:@"author" notEqualTo:[PFUser currentUser]];
// only fetch confessions that are not rated by current user
[qConfessions whereKey:@"objectId" doesNotMatchKey:@"confessionId" inQuery:qRatings];
// get all confessions from other users that are not rated by current user
[qConfessions findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// Success
} else {
// Error
}
}];