I have following case class
case class Tag(key: String, value: String, modifiedDate: Date)
And I have a data access object that looks like this:
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 ofTag
in update method to be replaced byCURRENT_TIMESTAMP
. How can it be done?
One alternative is before updating I set the modifiedDate
manually in the code
try to use copy
method from case class object and pass new Date contained current date:
def update(tag: Tag): Future[Int] =
performIO(
runIO(
quote {
query[Tag]
.filter(_.id == tag.id)
.update(
lift(tag.copy(modifiedDate = new Date()))
)
.returning(_.id)
}
)
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.