Query Parse Object based on empty relation

231 Views Asked by At

I have a parse object that I need to query based on a PFRelation property. I need to query for all objects in which the relation is empty and all objects in which the relation is not empty. What's the best approach for this? I'm using the iOS SDK.

1

There are 1 best solutions below

3
On
PFUser * currentUser = [PFUser currentUser];
PFRelation *relation = [currentUser relationForKey:@"habits"];
PFObject *object = [PFObject objectWithClassName:@"Habit"];
object[@"name"] = @"gym";

[object saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
       if (!error) {

            [relation addObject:object];
            [currentUser saveInBackground];

        }
    }];