首页 文章

Scala Slick理解问题

提问于
浏览
1

我在库中有以下内容:

案例分类:

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 <-Foos)yield f”,在Foos定义中,我们很高兴 . 如果我在使用这个库的代码库中的任何地方尝试它,我得到:

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

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

1 回答

  • 1

    尝试做:

    import slick.driver.MySQLDriver.simple._
    

    或者你需要的任何一个驱动程序 . 你需要隐式类来在 Foos 上提供 map 'extension'方法 .

相关问题