I have this code using slickdb:
val action: DBIOAction[Int, NoStream, Effect] =
for {
id <- sql"select id from product where name = $name".as[Int].head
_ <- sql"update product set description = ${description(id, name)}".asUpdate if id != 5
} yield id
db.run(action)
With this code, the action will not return the id
if id != 5
. This is not what I want. I want that the set description
update is only executed if id != 5
, and at the same time dbaction
must return the id
independenting or whether id != 5
or not.
How can I achieve this?