I have the following in a library:
Case Class:
case class Foo(
id: Option[Long],
bar: Long
...
)
Table:
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)
...
}
The data access layer is set up in the binary that utilizes these models. If I try a comprehension such as "for(f<-Foos) yield f", inside of the Foos definition, we're happy. If I try it anywhere in the codebase which uses this library, I get:
value map is not a member of object DB.this.Foos
My guess is it's not getting lifted into a Query, but I'm not entirely sure. Any clarity would be appreciated.
Try doing:
import slick.driver.MySQLDriver.simple._
or whichever driver it is that you need. You'll need the implicit classes in there to provide the map
'extension' method on Foos
.