는 (I 스칼라와 슬릭과 완전 초보자, 그래서 어떤 종류의 코드 리뷰에 감사드립니다) 내가 가지고있는 정의 class
및 슬릭 Table
다음테이블에서 호출 할 메소드는 어디에서 정의 할 수 있습니까?</p> <p>
case class Foo(title: String, description: String, id: Int = 0)
class FooTable(tag: Tag) extends Table[Foo](tag, "FOO") {
def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
def title = column[String]("TITLE", O.NotNull)
def description = column[String]("DESCRIPTION")
def * = (title, description, id) <> (Foo.tupled, Foo.unapply)
}
내가 방법을 추가 할을 title
과 일치하는 List
이 Foo
입니다. 이런 식으로 뭔가 :
def findByTitle(title: String) = DB.withSession { implicit s: Session =>
<FooTable TableQuery>.filter(_.title === title)
}
나는 다음과 같은 방법을 사용할 수있을 것입니다 :
val foos = TableQuery[FooTable]
DB.withSession { implicit s: Session =>
val anId = foos.findByTitle("bar")
}
방법/I 특정 Table
에 대한 TableQuery
에 따라 행동 할 수있는 방법을 추가 할 수있는? 신청서를 정리하는 것이 올바른 방법일까요?
감사합니다. Re : Scala Days 2013, 당신은 Slick 대 ORM 토크를 의미합니까? – sjwarner
예 Slick 대 ORM – cvogt
내 아키텍처는 DAO 사용에 대한 다양한 출처의 조언 덕분에 발전했습니다. 나는 지금 다른 환경에서 같은 문제를 다루려고한다. http://stackoverflow.com/questions/24669616/where-to-put-my-database-access-methods-when-using-a-dao- with-slick-2-0. 시간이 있으면 당신의 도움에 감사드립니다! – sjwarner