Slick 3 offers DBIOAction composition by using flatMap method. Also, we can do some calculations in back-end between two DBIOActions. That's works fine in most cases, but what I should do when calculations result is in the monad like Future? There is code with blocking way:
val fooQuery = TableQuery[FooTable]
val barQuery = TableQuery[BarTable]
def requestService(content: Iterable[String]): Future[Iterable[Long]] = ???
def modify(ids: Iterable[Long], change: String) = {
val query = fooQuery.filter(_.id inSet ids).result.flatMap{ fooSeq =>
val content = fooSeq.map(_.contentField)
val requestServiceFuture = requestService(content)
val serviceResult = Await.result(requestServiceFuture, 1.minute)
barQuery.filter(_.id inSet serviceResult).delete //or other action
}
db.run(query.transactionally)
}
Is there way to perform this code asynchronously, without Await?