您将如何在 SLICK 中编写此查询?
DB.withSession {
implicit session =>
Tokens.where(_.expirationTime < DateTime.now ).delete
}
DateTime.now 是 org.joda.time.DateTime 类型
和 _.expirationTime 是相同类型的类型映射列。
我收到这个错误
[error] UserService.scala:80: value < is not a member of scala.slick.lifted.Column[org.joda.time.DateTime]
[error] Tokens.where(_.expirationTime < DateTime.now ).delete
[error] ^
[error] one error found
现在使用这种形式的查询。
最佳答案
我的猜测是 JodaTime 类型不支持开箱即用的类型。如果您将该列更改为 java.sql.Timestamp
并使用了 Timestamp
作为您的比较值,事情会奏效。如果您想在光滑的列映射中使用 joda 类型,您可能需要查看以下内容:
https://github.com/tototoshi/slick-joda-mapper
关于scala - 在 Slick 中使用类型映射列进行查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17125076/