Reputation: 1389
This is how I update a row of table using Slick 2.1,
private def updateEntity(id: Long, row: TTable#TableElementType) = {
db.withSession { implicit session =>
val result = query.filter(_.id === id).update(row)
result.toLong
}
}
After I upgrade to Reactive Slick, db.withSession
showing deprecation warning as withSession deprecated. what is the
Action-based api syntax for updating a row.
Upvotes: 2
Views: 1212
Reputation: 4999
Slick 3.0 uses pure functional, monadic I/O without side effects. In Action based API, you will have to use db.run
which will take the Query
and return a Future
.
So in your case, it will be
private def updateEntity(id: Long, row: TTable#TableElementType): Future[Long] = {
db.run(query.filter(_.id === id).update(row)).map(_.toLong)
}
}
Upvotes: 3