Skip to content

Instantly share code, notes, and snippets.

@adamw
Created September 19, 2019 16:11
Show Gist options
  • Save adamw/367f7a0e8fab9e346581be1ab1a48009 to your computer and use it in GitHub Desktop.
Save adamw/367f7a0e8fab9e346581be1ab1a48009 to your computer and use it in GitHub Desktop.
def insertPerson(p: Person): ConnectionIO[Int] =
sql"INSERT INTO persons(name, age) VALUES(${p.name}, ${p.age})".update.run
def countPersons: ConnectionIO[Int] =
sql"SELECT COUNT(*) FROM persons".query[Int].unique
val insertAndCount =
insertPerson(Person("Pedro", 81)).flatMap(_ => countPersons)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment