Last active
          September 20, 2019 06:19 
        
      - 
      
 - 
        
Save adamw/008d4bc70326375c55ded513fa55d075 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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