使用Java中的count()过滤领域

Dra*_*ško 2 android count aggregate-functions realm

我正在使用最新的Realm(0.90.0)并且在一对多关系中有两个RealmObjects事件和游戏:

public class Event extends RealmObject
{
    ...
    private RealmList<Game> games;
}
Run Code Online (Sandbox Code Playgroud)

我希望过滤事件的条件之一,游戏数量必须大于0.我不知道如何在我的查询中包含该过滤器.

谢谢!

Chr*_*ior 5

您可以使用isEmpty:https://realm.io/docs/java/latest/api/io/realm/RealmQuery.html#isEmpty-java.lang.String-

例如

RealmResults<Event> results = realm.where(Event.class).not().isEmpty("games").findAll();
Run Code Online (Sandbox Code Playgroud)