Usually you would run two or more statements in a transaction. But in all the examples I could find on using transactionally
in Slick 3, there's a for/yield
statement to group these statements, when I usually use for
in a loop.
This works (deleting from two tables in a transaction):
val action = db.run((for { _ <- table1.filter(_.id1 === id).delete _ <- table2.filter(_.id2=== id).delete } yield ()).transactionally) val result = Await.result(action, Duration.Inf)
But is the for/yield
needed? is there an alteative way just to run two or more statements in a transaction?