val q1 = query.filter(_.value > 10) val q2 = q1.filter(_.value < 40) val q3 = q2.sortBy(_.date.desc) val q4 = q3.take(5)
我认为你应该做上面的事情(并传递Query
s),但如果你坚持传递查询"段",这样的事情可以工作:
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)