concept join in category scalatra

appears as: joins
Scalatra in Action

This is an excerpt from Manning's book Scalatra in Action.

There are Slick methods for each SQL join method: join for cross or inner joins, and leftJoin, rightJoin, and outerJoin. Each join operator fuses two queries into a single one, returning a tuple of the single result types. You can give a join condition using an on clause.

The following snippet shows examples for cross, inner, and left joins using applicative join syntax:

val crossJoin = areas join routes
val innerJoin = routes join areas on (_.areaId === _.id)
val leftJoin = areas joinLeft routes on (_.id === _.areaId)

The monadic join style uses flatMap to construct joins. For example, an inner join has a filter specifying the join condition: