How to make a nested query in Realm?

2020-06-03 01:55发布

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?

标签: realm
1条回答
太酷不给撩
2楼-- · 2020-06-03 02:23

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

RealmResults<ChatRealm> contacts = realm.where(ChatRealm.class).equalTo("users.id", "some id").findAll();
查看更多
登录 后发表回答