Reputation: 913
I'm using Realm 2.0 (Swift). My model is composed of X
and Y
(classes). X
has a property called list
which is a Realm List of Y
objects.
Let's assume I have an instance of a Y
object, called y
The query I'm looking for is:
y
in it's list of Y
objects?If the list was just a list of strings, I assume this would be trivial as the query would be: realm.objects(X.self).filter("<string> IN list")
Thanks :-)
Upvotes: 7
Views: 2037
Reputation: 18308
You can express this as either:
realm.objects(X.self).filter("%@ IN list", y)
or:
realm.objects(X.self).filter("ANY list = %@", y)
Upvotes: 9