【发布时间】:2012-12-13 09:59:16
【问题描述】:
我正在尝试学习使用 Slick 来查询 MySQL。我有以下类型的查询来获取单个访问对象:
Q.query[(Int,Int), Visit]("""
select * from visit where vistor = ? and location_code = ?
""").firstOption(visitorId,locationCode)
我想知道的是如何更改上述内容以查询以获取位置集合的 List[Visit] ......像这样:
val locationCodes = List("loc1","loc2","loc3"...)
Q.query[(Int,Int,List[String]), Visit]("""
select * from visit where vistor = ? and location_code in (?,?,?...)
""").list(visitorId,locationCodes)
Slick 可以做到这一点吗?
【问题讨论】:
-
这不行吗?应该工作。
-
你不能坚持使用元组值吗?它将保证您传递给查询的参数数量是固定的。
标签: scala typesafe-stack slick