Skip to content

Instantly share code, notes, and snippets.

@kciesielski
Created July 12, 2013 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kciesielski/fc65c5eb6e4b23251834 to your computer and use it in GitHub Desktop.
Save kciesielski/fc65c5eb6e4b23251834 to your computer and use it in GitHub Desktop.
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