Reputation: 397
I would like search for my favourite school names and its favourite student names like the following from my main table.
POINT GREY
kent
jane
michelle
MAGGEE
gary
john
shirley
However, I can only achieve getting the favourites student names using realm query:
RealmResults<Student> fav = realm.where(Student.class)
.equalTo("Favourite", "Yes")
.findAll();
My question is how to list my favourite schools and their favourite students in realm. Many Thanks.
My School class
public class School extends RealmObject {
@Required
private String SchoolID;
private String SchoolName;
private RealmList<Student> Students;
//getters, setters;
}
My Student Class
public class Student extends RealmObject{
@Required
private String StudentID;
private String StudentName;
private Boolean Favorite;
//getters, setters;
}
Upvotes: 0
Views: 310
Reputation: 20126
The concept you are looking for is called backlinks, which is an automatic reference between objects. You can see the issue here: https://github.com/realm/realm-java/issues/607
Until it is implemented you need to either manually maintain a reference from your Student to the School or make a query for it.
Upvotes: 1