简体   繁体   中英

Parse Query - cannot process more than one whereKey:doesNotMatchKey:inQuery

I was trying this

PFQuery *allDealsQuery = [Deal query];
PFRelation *favoritedDealsRelation = [user objectForKey:@"favoritedDeals"];
PFQuery *favoritedDealsQuery = [favoritedDealsRelation query];

PFRelation *redeemedDealsRelation = [user objectForKey:@"redeemedDeals"];
PFQuery *redeemedDealsQuery = [redeemedDealsRelation query];

[allDealsQuery whereKey:@"objectId" doesNotMatchKey:@"objectId" inQuery:favoritedDealsQuery];
//Parse does not support more than 2 where queries???
[allDealsQuery whereKey:@"objectId" doesNotMatchKey:@"objectId" inQuery:redeemedDealsQuery];

    [allDealsQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
            onSuccess(objects);
        }
        else {
            onError(error);
        }
    }];

When I tried to use two queries, the answer was different from what was expected. So should I use be using only one doesNotMatchKey query?

Try referencing parse documentation on Compound Queries: https://parse.com/docs/ios_guide#queries-compound/iOS

Compound Queries If you want to find objects that match one of several queries, you can use orQueryWithSubqueries: method. For instance, if you want to find players with either have a lot of wins or a few wins, you can do:

PFQuery *lotsOfWins = [PFQuery queryWithClassName:@"Player"];
[lotsOfWins whereKey:@"wins" greaterThan:@150];

PFQuery *fewWins = [PFQuery queryWithClassName:@"Player"];
[fewWins whereKey:@"wins" lessThan:@5];
PFQuery *query = [PFQuery orQueryWithSubqueries:@[fewWins,lotsOfWins]];
[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
  // results contains players with lots of wins or only a few wins.
}];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM