【发布时间】:2019-04-19 08:01:11
【问题描述】:
当前代码:
mRealm.where(AdditionalData.class)
.contains("checklistParticipants.email", a@a.com, Case.INSENSITIVE)
.equalTo("checklistParticipants.type", 0)
.findAll();
返回类似于ANY 记录的结果。
我想签入嵌套查询,仅在两个条件都满足时才返回记录。同样在嵌套查询中,记录电子邮件必须是 a@a.com 和 type=0
我尝试了以下方法,但结果相同。
mRealm.where(AdditionalData.class)
.contains("checklistParticipants.email",a@a.com, Case.INSENSITIVE)
.findAll()
.where()
.equalTo("checklistParticipants.type", 0)
.findAll();
下面的屏幕截图显示了 2 个子项,
- email= a@a.com & type = 1
- email= x@x.com & type = 0
领域在非此即彼的方法中检查这两个值。
也试过了:
mRealm.where(AdditionalData.class)
.equalTo("checklistParticipants.email",a@a.com, Case.INSENSITIVE)
.and()
.equalTo("checklistParticipants.type", 0)
.findAll()
classpath "io.realm:realm-gradle-plugin:5.8.0"
更新
class AdditionalData {
String name;
RealmList<ChecklistParticipants> checklistParticipants;
}
class ChecklistParticipants{
String email;
String type;
String field3;
}
【问题讨论】:
-
那是因为您应该通过
ChecklistParticipants查询,然后通过链接对象获取附加数据。 -
@EpicPandaForce- 我更新了我的问题,添加了模型,我在子对象中只有字段。我只想要父类的列表。
标签: realm realm-java