Delete and return Slick 3.0 values

If I want to return a value when inserting a new line, I can do something like

val insertQuery = myTable returning myTable.map(_.id) += SomeData(someString) 

How can I achieve the same effect when deleted?

I tried

 val deleteQuery = myTable filter (_.id ===id) returning myTable.map(_.someColumn) delete 

But apparently this does not compile.

I can resort to understanding for , but I wonder if there is a shorter way.

+4
source share
1 answer

The best way I know is to do something like:

 val query = db.filter(....) val action = for { results <- query.result _ <- query.delete } yield results db.run(action.withTransactionIsolation(TransactionIsolation.RepeatableRead)) 

Wish it was shorter.

+2
source

All Articles