Skip to content

Instantly share code, notes, and snippets.

@kciesielski
Last active December 19, 2015 16:18
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/26f4278ddd6d6b513e0e to your computer and use it in GitHub Desktop.
Save kciesielski/26f4278ddd6d6b513e0e to your computer and use it in GitHub Desktop.
def loadUser(searchedNameOpt: Option[String], searchedAgeOpt: Option[Int]) = {
val getAllQuery = (UserRecord limit 5 orderDesc (_.age)).query
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 fetch()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment