我想知道是否有直接的方法来查询 realmObjects 的 realmList 等于另一个 realmList。
例子:
public class Tags extends RealmObject{
@PrimaryKey
private String ID = UUID.randomUUID().toString();
private String tag;
}
public class Article extends RealmObject {
@PrimaryKey
private String ID = UUID.randomUUID().toString();
private RealmList<Tags> tags;
}
RealmList<Tags> userTags;
Article article = mDB.where(Article.class).equalTo("tags", userTags).findFirst();
最佳答案
不,但您可以使用 in
query condition 创建链接查询.
RealmList<Tags> userTags = ...;
Set<String> tags = new LinkedHashSet<>();
for(Tags tag : userTags) {
ids.add(tag.getTag());
}
String[] tagArray = tags.toArray(new String[tags.size()]);
Article article = mDB.where(Article.class).in("tags.tag", tagIdArray).findFirst();
关于android - 查询 realmObject,其中 realmList 等于另一个 realmList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44498132/