I have the following Slick function that has a filter (d.sk < sk):
def func1(sk: Int) = {
val date2 = TableQuery[DatesDB]
val action = date2.filter( d => (d.sk < sk)).result
val future = db.run(action.asTry)
future.map {
case Success(s) =>
if (s.length > 0)
Some(s(0))
else
None
case Failure(e) => throw new Exception("Failure")
}
}
What I need is to add a feature to this function that depending on a condition X the filter should be either the existent one or (d.sk <= sk). Since filters are not variables I don't know how to achieve this, and I prefer not to rewrite the filters or actions. Any ideas?