Forsan Al-Sharabati
Forsan Al-Sharabati

Reputation: 31

Parse.com query with relation

Im try to run this query in parse.com, But Everyone not working.

I have 2 tables, One for Promote and second for Archive.

So, I need to fetch all rows in Promote table where is not in archive table.

Like this SELECT * FROM promote WHERE id NOT IN (SELECT promoteID FROM archive WHERE user=userID).

promoteID in archive is Pointer to objectId in Promote Table.

any help Please?

Upvotes: 0

Views: 74

Answers (1)

TonyMkenu
TonyMkenu

Reputation: 7667

Try something like this....

PFQuery *innerQuery = [PFQuery queryWithClassName:@"Archive"];
[innerQuery whereKey:@"user" equalTo:[PFUser currentUser]];
[innerQuery orderByDescending:@"createdAt"];

PFQuery *query = [PFQuery queryWithClassName:@"Promote"];
[query whereKey:@"id" doesNotMatchQuery:innerQuery];
[query findObjectsInBackgroundWithBlock:^(NSArray *records, NSError *error) {
    if (error) return;
    for (PFObject *record in records) {
        // .....

       }
}];

Upvotes: 1

Related Questions