【发布时间】:2020-04-05 13:59:17
【问题描述】:
我有以下案例类
case class Tag(key: String, value: String, modifiedDate: Date)
我有一个如下所示的数据访问对象:
class TagDao(implicit val ec: ExecutionContext, val ctx: PostgresAsyncContext[SnakeCase]) {
def update(tag: Tag): Future[Int] =
performIO(
runIO(
quote {
query[Tag]
.filter(_.id == tag.id)
.update(lift(tag))
.returning(_.id)
}
)
)
}
我希望将更新方法中
Tag的modifiedDate字段替换为CURRENT_TIMESTAMP。怎么办?
另一种选择是在更新之前我在代码中手动设置modifiedDate
【问题讨论】:
-
我最终使用了数据库触发器