Skip to content

Instantly share code, notes, and snippets.

@privateblue
Created November 25, 2013 23:18
Show Gist options
  • Save privateblue/7650658 to your computer and use it in GitHub Desktop.
Save privateblue/7650658 to your computer and use it in GitHub Desktop.
import scala.slick.driver.H2Driver.simple._
object MyRepository {
val table = new Table[(Int, String)]("my_table") {
def id = column[Int]("id", O.PrimaryKey)
def name = column[String]("name")
def * = id ~ name
}
def getName(id: Int): Future[String] =
MySlickPools.myReadPool execute { implicit session =>
Query(table).filter(_.id === id).map(_.name).first
}
def insert(id: Int, name: String) =
MySlickPools.myWritePool execute { implicit session =>
table.insert((id, name))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment