简体   繁体   中英

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?

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) {
        // .....

       }
}];

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