Skip to content

Instantly share code, notes, and snippets.

@adamw adamw/t11.scala
Last active Sep 20, 2019

Embed
What would you like to do?
val countPersons: ConnectionIO[Int] =
sql"SELECT COUNT(*) FROM persons".query[Int].unique
val callFromCount: ConnectionIO[IO[Unit]] = countPersons.map { count =>
if (count == 0) IO(println("No users!")) else IO(println(s"Found $count users"))
}
val showResults: IO[Unit] = callFromCount.transact(transactor).flatten
showResults.unsafeRunSync()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.