2
在表slick documentation列與def
爲什麼列表中的表格是defs而不是vals?
class Coffees(tag: Tag) extends Table[(String, Int, Double, Int, Int)](tag, "COFFEES") {
def name = column[String]("COF_NAME", O.PrimaryKey)
def supID = column[Int]("SUP_ID")
def price = column[Double]("PRICE")
def sales = column[Int]("SALES", O.Default(0))
def total = column[Int]("TOTAL", O.Default(0))
def * = (name, supID, price, sales, total)
}
確定是否有一個原因,它不應該是這樣的:
class Coffees(tag: Tag) extends Table[(String, Int, Double, Int, Int)](tag, "COFFEES") {
val name = column[String]("COF_NAME", O.PrimaryKey)
val supID = column[Int]("SUP_ID")
val price = column[Double]("PRICE")
val sales = column[Int]("SALES", O.Default(0))
val total = column[Int]("TOTAL", O.Default(0))
val * = (name, supID, price, sales, total)
}
好像列不使用任何可能改變。