如何在Slick 2.0中计算(*)? [英] How to COUNT(*) in Slick 2.0?
本文介绍了如何在Slick 2.0中计算(*)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据 Slick 2.0文档, 获取表中的行数:
According to the Slick 2.0 documentation, to get the count of rows in a table:
val q1 = coffees.length
// compiles to SQL (simplified):
// select count(1) from "COFFEES"
但是,事实证明coffees.length
是Column[Int]
类型.
However, it turns out that coffees.length
is of type Column[Int]
.
一个人如何执行查询并获取值?
How does one execute the query and get the value?
推荐答案
我刚刚升级到slick 2.0时遇到了同样的问题.我忘记了确切方法的用途,但是通用.run
似乎对我有用,即
I just had this same problem upgrading to slick 2.0. I forget where the exact method lives, but the generic .run
seems to work for me, i.e.
coffees.length.run
这篇关于如何在Slick 2.0中计算(*)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文