-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
Sometimes you really want to get some other objects than the one you are querying. Example from link queries:
- I want to find all Persons with a dog that is brown and called Fluffy.
That is currently only possible when querying Persons:
RealmResults<Owner> r2 = realm.where(Owner.class) .equalTo("dogs.name", "Fluffy") .findAll() .where() .equalTo("dogs.color", "Brown") .findAll();
With a collect operator you could do instead:
RealmResults<Owner> = realm.where(Dog.class) .equalTo("name", "Fluffy") .equalTo("color", "Brown") .findAll() .collectAll(Owner.class, "owner") // Dog needs a owner field
Overriding findAll could also be an option, although I probably like the collect operator more as it is also a well known functional method.
RealmResults<Owner> = realm.where(Owner.class) .equalTo("name", "Fluffy") .equalTo("color", "Brown") .findAll(Owner.class, "owner);
What do you think @realm/java
EDIT: Or maybe the above is just a symptom that the current query language are missing some features since findAll already is a collect statement, so we should fix that instead.