If I want a returning value when inserting a new row, I can do something like
val insertQuery = myTable returning myTable.map(_.id) += SomeData(someString)
How can I achieve the same effect when deleting?
I tried
val deleteQuery = myTable filter (_.id ===id) returning myTable.map(_.someColumn) delete
But apparently this does not compile.
I can resort to the for
comprehension but I wonder if there is a shorter way.
The best way I know of to do this 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With