2
votes

I want to create a PFQuery for a PFRelation to find objects where the specified relation has zero objects in it. Here's what I've tried:

PFQuery *categoryQuery = [CatalogCategory query];
[categoryQuery whereKeyDoesNotExist:@"subcategories"];

But I get an error saying I can't use this operator on a PFRelation key. How else could I achieve what I'm looking for?

1
From what I understand you would use a PFRelation query after getting the objects first, just like you can't save a relation to an object that hasn't been saved first. Something like PFRelation *relation = [yourObjectInstanceHere relationforKey:@"subcategories"] - soulshined
Yeah but I don't have an objectInstance to start with. I'm searching for objects that don't have any subcategories, so my starting point is "all objects". I don't know if that makes sense or not. - Cory Imdieke
Exactly, so you find all the objects first (without parameters) or not, then do a PFRelation query : see here: parse.com/docs/ios/guide#relations-using-parse-relations second topic - soulshined

1 Answers

0
votes

Have you tried [categoryQuery whereKey:@"subcategories" equalTo:nil]?

It may be that the whereKeyDoesNotExist: method is unavailable for objects of the PFRelation type.