Scala Slick理解问题

时间:2013-09-28 23:52:39

标签: scala slick scalaquery

我在库中有以下内容:

案例分类:

case class Foo(
  id: Option[Long],
  bar: Long
...
)

表:

object Foos extends Mapper[Foo]("foo"){ //I'm using slick-inegration so the id is free
  def bar = column[Long]("bar")
  def cols = bar ~ ...
  def * = id.? ~: cols <> (Foo, Foo.unapply _)
  def returningId = cols returning id
  def insert(f: Foo)(implicit s: Session) = returningId.insert(Generic[Foo].to(f).tail.tupled)

...
}

数据访问层在使用这些模型的二进制文件中设置。如果我尝试理解诸如“for(f&lt; -Foos)yield f”,在Foos定义中,我们很高兴。如果我在使用这个库的代码库中的任何地方尝试它,我得到:

value map is not a member of object DB.this.Foos

我的猜测是它没有被提升到查询中,但我不完全确定。任何清晰度都将不胜感激。

1 个答案:

答案 0 :(得分:1)

尝试做:

  import slick.driver.MySQLDriver.simple._

或者您需要的任何一个驱动程序。您需要其中的隐式类才能在map上提供Foos'扩展'方法。

相关问题