I have a RealmObject
(let's say Owner
) and it has RealmList<Cat>
. Cat
has a property name
. How do I query for all the Owner
s who have cat with specified name ?
I tried:
RealmResult<Owner> owners = realm.query(Owner.class)
.contains("cats", "Garfield")
.findAll();
But it does not work.
PS most probably duplicate but cant find.
.
can be used when query child object/list fields, for your case try below:
RealmResult<Owner> owners = realm.query(Owner.class)
.contains("cats.name", "Garfield")
.findAll();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With