如何在SLICK中提取聚合查询的结果? [英] How can I extract results of aggregate queries in slick?
本文介绍了如何在SLICK中提取聚合查询的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想检查是否存在满足特定条件的行:
// Method defined on type T
def exists(some_data : Long, other_data : Long) : Boolean = DB.withSession { implicit session : Session =>
(for {
row <- table // table is a Table[T]
if row.some_data =!= some_data
if row.other_data === other_data
} yield row).length > 0
}
我收到此错误:
polymorphic expression cannot be instantiated to expected type;
[error] found : [R]scala.slick.lifted.Column[R]
[error] required: Boolean
知道这是怎么回事吗?现在,我只是将结果转换为Scala列表(而不是.length
,我有.list.length
)并检查它的长度,但我不应该这样做。我在列上找不到任何方法来帮助我提取值。
推荐答案
使用:.length.run
.length
returns a Column[Int],调用the method .run
时为implictly converted to an Executor
这篇关于如何在SLICK中提取聚合查询的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文