Another question answers how to define a one-to-many association, by defining a method in the "one" case class (Directorate
) that returns a Seq
of the "many" class (ServiceArea
).
But it doesn't address the "bidirectional" part of the question.
Using that example, I'd like to see how to traverse the association from the other direction. Instead of
case class ServiceArea(areaCode: String, dirCode: String, name: String)
I'd like to see
case class ServiceArea(areaCode: String, directorate: Directorate, name: String)
Is this possible with Slick? Because when I try something like
object ServiceAreas ...
def * = areaCode ~ directorate ~ name <> (ServiceArea, ServiceArea.unapply _)
it fails to compile, not finding an implicit value for evidence parameter of type TypeMapper[ForeignKeyQuery[ServiceAreas,ServiceArea]]
.