I am pretty used to writing the standard slick boiler plate code like this.
Suppose I am creating a table called Foo with columns id and name. We can write
case class Foo(id: Long, name: String)
final class FooTable(tag: Tag) extends Table[Foo](tag, "foo") {
def id = column[Long]("id")
def name = column[String]("name")
def * = (id, name) <> (Foo.tupled, Foo.unapply)
}
But what if I wanted a single column table where Foo just has a name. The code below does not compile because Now Foo does not have the tupled method anymore.
case class Foo(name: String)
final class FooTable(tag: Tag) extends Table[Foo](tag, "foo") {
def name = column[String]("name")
def * = (name) <> (Foo.tupled, Foo.unapply)
}
I found this thread on SO
Scala projections in Slick for only one column
and changed my code to
case class Foo(name: String)
final class FooTable(tag: Tag) extends Table[Foo](tag, "foo") {
def name = column[String]("email_address")
def * = (name)
}
but still doesn't compile