Skip to content

Instantly share code, notes, and snippets.

@Christewart
Created January 11, 2017 17:31
Show Gist options
  • Save Christewart/591061ba6cbe2bff03b6c31860984458 to your computer and use it in GitHub Desktop.
Save Christewart/591061ba6cbe2bff03b6c31860984458 to your computer and use it in GitHub Desktop.
/** Updates all of the given ts in the database */
def updateAll(ts: Seq[T]): Future[Seq[T]] = {
val query = findAll(ts)
val actions = ts.map(t => query.update(t))
val affectedRows: Future[Seq[Int]] = database.run(DBIO.sequence(actions))
val updatedTs = findAll(ts)
affectedRows.flatMap { _ =>
database.run(updatedTs.result)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment