Skip to content

Instantly share code, notes, and snippets.

@thetrav
Created April 6, 2017 03:44
Show Gist options
  • Save thetrav/5280e60aa1eae6ddf625ad0457dc9c91 to your computer and use it in GitHub Desktop.
Save thetrav/5280e60aa1eae6ddf625ad0457dc9c91 to your computer and use it in GitHub Desktop.
generic Dao with Trait
trait Dao[T] {
val tableName: String
def find(id:String): ConnectionIO[Option[T]] =
Fragment.const("select * from $tableName where id = ") ++ fr"$id".query[T]
}
case class Foo(id: String, data: String)
object Foos extends Dao[Foo] {
val tableName = "foos"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment