简体   繁体   中英

How to search RealmList field of RealmObj

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?

Sure, using a link query

RealmResults<Person> persons = realm.where(Person.class)
                                   .equalTo("phoneNumbers.phoneNumber", phoneNumber)
                                   .findAllAsync();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM