Laranjeiro
Laranjeiro

Reputation: 2622

How to make a nested query in 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?

Upvotes: 14

Views: 3133

Answers (1)

Valentin Blokhin
Valentin Blokhin

Reputation: 515

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

RealmResults<ChatRealm> contacts = realm.where(ChatRealm.class).equalTo("users.id", "some id").findAll();

Upvotes: 13

Related Questions