How to do “OR” filter in slick

后端 未结 1 1832
醉话见心
醉话见心 2021-01-04 08:29

In slick we can use

query.filter( m => (m.state === state1 && m.status === status1) || (m.state === state2 && m.status == status2)) 


        
相关标签:
1条回答
  • 2021-01-04 09:06

    While playing around with it, I finally found a way to do it:-

    query.filter {
      m => conditions.map(n => m._13 === n._1 && m._14 === n._2).reduceLeft(_ || _)
    }
    

    where conditions is of the form List[(String,String)], m._13 maps to state and m._14 maps to status.

    Hopefully this will help someone trying out same thing.

    0 讨论(0)
提交回复
热议问题