Skip to content

Use mappedWith to map an HList into a case class

Compare
Choose a tag to compare
@d6y d6y released this 26 Sep 08:26
· 65 commits to master since this release

Addition of the mappedWith method.
This allows a user to convert an HList shape mapping to a case class shape mapping using a Generic:

case class Address(id: Long, house: Int, street: String)

class Addresss(tag: Tag) extends Table[Address](tag, "addresses") {
  def id     = column[Long]("id", O.PrimaryKey, O.AutoInc)
  def house  = column[Int]("house")
  def street = column[String]("street")

  def * = (id :: house :: street :: HNil).mappedWith(Generic[Address])
}

Thanks @davegurnell and PR 10.