0

I have the following query:

PFObject *photoData = [PFObject objectWithClassName:@"Photos"];
PFRelation *relation = [photoData relationForKey:@"photo"];
PFQuery *query = [PFQuery queryWithClassName:@"People"];
query = [relation query];
[query whereKey:@"deleted" equalTo:@NO];
[query whereKey:@"createdAt" lessThan:_createdAt];
[query orderByDescending:@"createdAt"];
query.limit = 20;
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    ...
}

I have a database table in Parse called People. In that table, there is a bunch of data but has a relation called photo. Now, I am saving one photo (with its data) in the photo relation. In the Parse dashboard, the data is saved correctly.

How do I fetch that back? Right now I have constraints on this system (and question) that each People objects has ONLY one photo object. So I need to fetch it all back at once.

1 Answer 1

1

Relation is just what its literal meaning is. It does not contain any data. If you want to query the data, you need to get the PFQuery from PFRelation by query method like so:

PFRelation *relation = [photoData relationForKey:@"photo"];
PFQuery *photoQuery = [relation query];
// perform your photoQuery here

If you limit them by one object only, then you can change your photo as Pointer type instead of using Relation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.