2

I'm using latest Realm (0.90.0) and have two RealmObjects Event and Game in one-to-many relationship:

public class Event extends RealmObject
{
    ...
    private RealmList<Game> games;
}

I wish to filter Events with one of the conditions that count of games must be bigger than 0. I am not sure how to include that filter in my query.

Thanks!

Draško
  • 2,119
  • 4
  • 41
  • 73

1 Answers1

5

You can use isEmpty: https://realm.io/docs/java/latest/api/io/realm/RealmQuery.html#isEmpty-java.lang.String-

e.g

RealmResults<Event> results = realm.where(Event.class).not().isEmpty("games").findAll();
Christian Melchior
  • 19,978
  • 5
  • 62
  • 53