Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a nested query in Realm?

Tags:

realm

I have two realms:

public class ChatRealm extends RealmObject {
    private String id;
    private RealmList<UserRealm> users;
}

public class UserRealm extends RealmObject {
    private String id;
    private String username;
}

I have an User id and I want to know which chats he is participating in. I have check the Realm documentation and couldn't find how to do this type of queries.

How can I get the results I want using a Realm query?

like image 993
Laranjeiro Avatar asked Jun 03 '15 09:06

Laranjeiro


1 Answers

How about link query in documentation? There is an example:

RealmResults<ChatRealm> contacts = realm.where(ChatRealm.class).equalTo("users.id", "some id").findAll();
like image 140
Valentin Blokhin Avatar answered Oct 24 '22 09:10

Valentin Blokhin