-
-
Save kciesielski/fc65c5eb6e4b23251834 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def loadUser(searchedNameOpt: Option[String], searchedAgeOpt: Option[Int]) = { | |
val getAllQuery = UserRecord | |
val queryByName = searchedNameOpt map(searchedName => getAllQuery where (_.name eqs searchedName)).getOrElse(getAllQuery) | |
val finalQuery = searchedAgeOpt map(searchedAge => queryByName and(_.age eqs searchedAge)).getOrElse(queryByName) | |
finalQuery.orderDesc(_.age).limit(5).fetch() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment