这个问题与无法包含原始类型列表问题有关[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();
最佳答案
RealmResults<Thing> things = realm.where(Thing.class)
.equalTo("tags.tag", searchValue)
.findAll();
关于java - 按字符串数组字段过滤 Realm 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39906897/