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)
}
好像列不使用任何可能改变。