val q1 = query.filter(_.value > 10) val q2 = q1.filter(_.value < 40) val q3 = q2.sortBy(_.date.desc) val q4 = q3.take(5)
I think you should do something like the above (and skip Query s), but if you insist on going around the "segments" of the query, something like this might work:
type QuerySegment = Query[SomeThingValid, SomeThingValid, Seq] => Query[SomeThingValid, SomeThingValid, Seq] val q1: QuerySegment = _.filter(_.value > 10) val q2: QuerySegment = _.filter(_.value < 40) val q3: QuerySegment = _.sortBy(_.date.desc) val q4: QuerySegment = _.take(5) val finalQ = Function.chain(Seq(q1, q2, q3, q4))(query)
source share