Java RethinkDB 预期类型 DATUM 但发现选择 [英] Java RethinkDB Expected type DATUM but found SELECTION
问题描述
我正在使用用于 Java 的 RethinkDB 驱动程序.我想过滤表 jam
中没有字段 endedAt
的行,如下所示:
I'm using RethinkDB driver for Java. I want to filter the rows without field endedAt
in table jam
like this:
public List<Jam> getCurrent(){
Cursor cursor = r.table("jam")
.filter(row -> row.hasFields("endedAt")).not()
.run(conn);
List<Map<String,Object>> list=cursor.toList();
return list.stream().map(item->JamRepository.toJam(item)).collect(Collectors.toList());
}
我有这个错误 预期类型 DATUM 但发现 SELECTION Java
我在另一个类中有另一个过滤器函数:
I have another filter function in another class:
public List<Speedlog> getByTime(long time){
Cursor cursor = r.table("speedlog")
.filter(row -> row.g("createdAt").eq(time))
.run(conn);
List<Map<String,Object>> list=cursor.toList();
return list.stream().map(item->SpeedlogRepository.toSpeedlog(item)).collect(Collectors.toList());
}
此功能正常运行
谁能解释一下这两者之间的区别?为什么 getCurrent
函数会得到那个错误?它的含义是什么以及如何修复?谢谢
Could anyone please explain what makes the difference between these two? Why does getCurrent
function get that error? What is its meaning and how to fix? Thank you
推荐答案
not()
应该紧跟在 row.hasFields("endedAt")
之后.现在,您正在尝试对 filter
函数的结果调用 not()
.所以,正确的代码:
not()
should be right after row.hasFields("endedAt")
. For now you are trying to call not()
on the result of filter
function. So, correct code:
public List<Jam> getCurrent(){
Cursor cursor = r.table("jam")
.filter(row -> row.hasFields("endedAt").not())
.run(conn);
List<Map<String,Object>> list=cursor.toList();
return list.stream().map(item->JamRepository.toJam(item)).collect(Collectors.toList());
}
这篇关于Java RethinkDB 预期类型 DATUM 但发现选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!