scala - Count rows with Slick 1.0.0 -
i'm trying create query slick 1.0.0 returns row count equivalent next sql statement:
select count(*) table;
what have far is:
val query = { row <- table } yield row println(query.length)
this prints scala.slick.ast.functionsymbol$$anon$1@6860991f
. also, query.length
appears of type scala.slick.lifted.column
. cannot find way execute query. examples can find in documentation , anywhere else not operate on column
or scalaquery , not work anymore.
what can execute this?
any of these should trick:
query(mytable).list.length
or
(for{mt <- mytable} yield mt).list.length
or
(for{mt <- mytable} yield mt.count).first
update:
printing h2 database log shows lastly query, looks optimal:
03:31:26.560 [main] debug h2database - jdbc[2] /**/preparedstatement prep10 = conn1.preparestatement("select select count(1) \"mytable\" s5", 1003, 1007);
scala slick
No comments:
Post a Comment