按字符串数组字段筛选领域结果

时间:2016-10-06 23:00:01

标签: java realm

这个问题与无法包含原始类型问题列表有关[1]。当前的,相当弱的文档解决方案[2]表示使用自定义RealmString对象。不幸的是,该解决方案仅显示在使用RealmString时如何保存值。如何执行嵌套过滤器,如下所示?

class Thing extends RealmObject {
    public RealmList<Tag> tags;
}

class Tag extends RealmObject {
    private String tag;
    public String getTag() { return tag; }
    public void setTag(String tag) { this.tag = tag; }
}

// how do you perform the search here? equalTo, contains?
RealmResults<Thing> things = realm.where(Thing.class).equalTo("tags", searchValue).findAll(); 
  1. https://github.com/realm/realm-java/issues/575
  2. What is the best way to use List<String> in Realm Android?

1 个答案:

答案 0 :(得分:1)

Link Queries

RealmResults<Thing> things = realm.where(Thing.class)
                                  .equalTo("tags.tag", searchValue)
                                  .findAll();