Created
November 25, 2013 23:18
-
-
Save privateblue/7650658 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
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