Slide 54
Slide 54 text
*OGSBTUSVDUVSFͷ࣮ྫ4MJDL
trait CustomerTable extends ColumnMappers {
this: Profile =>
import profile.api._
class Customers(tag: Tag) extends Table[CustomerRow](tag, "customer") {
def id = column[ID[Customer]]("id", O.SqlType("INT"), O.PrimaryKey, O.AutoInc)
def email = column[String]("email", O.SqlType("VARCHAR(256)"))
def status = column[CustomerStatus]("status", O.SqlType("INT"))
...
type TableRecord = (Option[ID[Customer]], String, CustomerStatus)
def * = (id.?, email, status) <> (
(t: TableRecord) => {
val (id, email, status_) = t
CustomerRow(id, email, status)
},
(customer: CustomerRow) => {
Option((customer.id, customer.email, customer.status))
}
)
}
}
4DBMBؔ 4VNNJU