I'm using Realm-Java
for an Android application.
I need to query a list of MyObject
, searching for the ones that contain a string in MyObject.SubObject_A.ListOfString
.
Since Realm doesn't support list of String
, I'm now using this structure:
-MyObject
----SubObject_A
--------Attribute_A
--------Attribute_B
--------RealmList<RealmString>
----SubObject_B
----OtherStuff
With RealmString
being
public class RealmString extends RealmObject {
public static final String VALUE = "value";
private String value;
}
How do I query for all MyObject
that contain a given String inside MyObject.SubObject_A.RealmList<RealmString>
?
You're looking at link queries. You should be able to do something like this to get a RealmResults<MyObject>
.
realm.where(MyObject.class).equalTo("subObject_A.stringList.value", "search string").findAll();
The idea is that you're able to use a condition in equalTo
that contains the path through the relationships separated by period.
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