Created
April 6, 2017 03:44
-
-
Save thetrav/5280e60aa1eae6ddf625ad0457dc9c91 to your computer and use it in GitHub Desktop.
generic Dao with Trait
This file contains 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
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