英文:
How to search RealmList field of RealmObj
问题
我有一个类似这样的 Realm 对象:
public class Person extends RealmObject {
private String fullName;
private RealmList<PhoneNumberObj> phoneNumbers;}
其中 PhoneNumberObj 类的结构如下:
public class PhoneNumberObj extends RealmObject {
private String phoneNumber;
private String type;
}
是否可以使用 Realm 查询来查找具有特定 phoneNumber 的人?
英文:
I have a realm object like:
public class Person extends RealmObject {
private String fullName;
private RealmList<PhoneNumberObj> phoneNumbers;}
Where the class PhoneNumberObj looks like:
public class PhoneNumberObj extends RealmObject {
private String phoneNumber;
private String type;
}
Is it possible to use a realm query to find a person with a specific phoneNumber?
答案1
得分: 1
当然,使用链接查询
RealmResults<Person> persons = realm.where(Person.class)
.equalTo("phoneNumbers.phoneNumber", phoneNumber)
.findAllAsync();
英文:
Sure, using a link query
RealmResults<Person> persons = realm.where(Person.class)
.equalTo("phoneNumbers.phoneNumber", phoneNumber)
.findAllAsync();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论