您好,我刚刚更新并运行了 simple slick Table,想查询它。
import scala.slick.driver.PostgresDriver.simple._
import scala.slick.lifted.TableQuery
class Coffees(tag: Tag) extends Table[(String, Double)](tag, "COFFEES") {
def name = column[String]("COF_NAME", O.PrimaryKey)
def price = column[Double]("PRICE")
def * = (name, price)
}
val coffees = TableQuery[Coffees];
错误是:
[error] C:\testprojects\slickplay\app\model\Coffee.scala:11: expected class or o bject definition
[error] val coffees = TableQuery[Coffees];
TableQuery[Coffees] 不返回对象???如何解决。
最佳答案
您不能在类或对象定义之外拥有 val。
尝试
object DatabaseContext {
val coffees = TableQuery[Coffees]
}
关于scala - slick2.0 : how to make a Table object?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22525222/