我是第一次使用ObjectBox,所以我一直在尝试使用它的查询系统来熟悉它。其中一个查询是比较两个属性的查询。忽略它们抛出的错误,下面是我希望做的一些例子:
// Get objects where first number is bigger than second number
boxA.query(ObjectA_.firstNumber.greaterThan(ObjectA_.secondNumber))
// Get parent objects where one of its children has a specific value from the parent
parentBox.query().linkMany(ParentObject_.children, ChildObject_.name.equals(ParentObject_.favoriteChild));
我知道based on this question在Java中可以使用过滤器,但我也知道ObjectBox for Dart中没有查询过滤器。我测试的一个解决方案是查询一个属性,获取值,然后使用每个值查询第二个属性。但即使在中等大小的数据量下,这也是不可持续的。
如果有人知道一种不使用Java过滤器的“正确”方法,那就太好了,否则,如果有比我想到的更好的解决方案,那也太好了。
1条答案
按热度按时间cngwdvgl1#
ObjectBox中没有针对Dart的查询过滤器API,因为Dart已经具有where API。
例如,对于结果列表,写入
results.where((a) => a.firstNumber >= a.secondNumber)
。