使用函数更新scala Quill中的case class值

Using function to update case class value in scala Quill

我有以下案例class

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)
        }
      )
    )
}

I want modifiedDate field of Tag in update method to be replaced by CURRENT_TIMESTAMP. How can it be done?

一种替代方法是在更新之前我在代码中手动设置 modifiedDate

尝试使用案例 class 对象中的 copy 方法并传递包含当前日期的新日期:

def update(tag: Tag): Future[Int] = 
    performIO(
      runIO(
        quote {
          query[Tag]
            .filter(_.id == tag.id)
            .update(
              lift(tag.copy(modifiedDate = new Date()))
            )
            .returning(_.id)
        }
      )
    )