Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to acces data in a relation using parse.com

I am using Parse.com, and I have in Data Browser the following tables: User (the default user table) and studyYears. In my User table, I have multiple users. I have added to the user table a column of Relation type that refers to another table called studyYears. The studyYears table only contains a string column called year.

How can I make a query that for a user I will get the values from the year column of the studyYears table?

I hope somebody can understand what I am trying to get. Thanks in advance!

like image 579
Carmichael Avatar asked Jan 27 '26 19:01

Carmichael


1 Answers

http://blog.parse.com/2012/05/17/new-many-to-many/ states:

When you fetch the Place object, the objects in the relations won’t be fetched, which is a huge win for a relationship with a large number of objects. Even without fetching all the objects in the relation, you can add objects to the relation using add:. If you wanted to fetch all the objects in the relations, you would do something like:

PFRelation *relation = [place relationForKey:@"likes"];
PFQuery *query = [relation query];
[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
    // results contains all the people who liked Sid's BBQ.
}];
like image 53
Peteee24 Avatar answered Jan 30 '26 10:01

Peteee24



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!