gpt4 book ai didi

realm - 如何查询具有包含指定值的RealmList的RealmObject

转载 作者:行者123 更新时间:2023-12-04 05:11:56 25 4
gpt4 key购买 nike

我有一个RealmObject(让我们说Owner),它有RealmList<Cat>Cat具有属性name。如何查询所有具有指定名称的cat的Owner

我试过了:

RealmResult<Owner> owners = realm.query(Owner.class)
.contains("cats", "Garfield")
.findAll();

但这是行不通的。

PS最有可能重复但找不到。

最佳答案

查询子对象/列表字段时可以使用.,对于您的情况,请尝试以下操作:

RealmResult<Owner> owners = realm.query(Owner.class)
.contains("cats.name", "Garfield")
.findAll();

关于realm - 如何查询具有包含指定值的RealmList的RealmObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34924574/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com