How to make a nested query in Realm?

扶醉桌前 提交于 2019-12-03 17:07:31

问题


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?


回答1:


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

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


来源:https://stackoverflow.com/questions/30616140/how-to-make-a-nested-query-in-realm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!