ios – 或使用include查询

前端之家收集整理的这篇文章主要介绍了ios – 或使用include查询前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个连接表,其中包含from列和a列.两列都指向用户对象.执行此OR查询时,它会抛出错误:’OR查询不支持包含’的子查询

有没有办法解决?谢谢!

//设置查询获取当前用户与其他用户联系的所有关系.

PFQuery *userIsFriendSender = [PFQuery queryWithClassName:@"UserRelationships"];
[userIsFriendSender whereKey:@"from" equalTo:[PFUser currentUser]];
[userIsFriendSender whereKey:@"active" equalTo:@YES];

[userIsFriendSender includeKey:@"to"];

// set up query to get all relationships where a use friended the current user
PFQuery *userIsFriendReceiver = [PFQuery queryWithClassName:@"UserRelationships"];
[userIsFriendReceiver whereKey:@"to" equalTo:[PFUser currentUser]];
[userIsFriendReceiver whereKey:@"active" equalTo:@YES];

[userIsFriendReceiver includeKey:@"from"];

PFQuery *query = [PFQuery orQueryWithSubqueries:@[userIsFriendSender,userIsFriendReceiver]];

解决方法

@H_404_11@ 尝试将includeKey:子句移动到联合查询.
PFQuery *query = [PFQuery orQueryWithSubqueries:@[userIsFriendSender,userIsFriendReceiver]];
[query includeKey:@"from"];
[query includeKey:@"to"];
原文链接:https://www.f2er.com/iOS/330724.html

猜你在找的iOS相关文章