Skip to content

Instantly share code, notes, and snippets.

@karthik20522
Created May 25, 2019 06:47
Show Gist options
  • Save karthik20522/ee21e0f6311ba42c4fb0e8f087a98fb8 to your computer and use it in GitHub Desktop.
Save karthik20522/ee21e0f6311ba42c4fb0e8f087a98fb8 to your computer and use it in GitHub Desktop.
select * from users order by age desc
abstract class Direction
case class Asc(field: String*) extends Direction
case class Desc(field: String*) extends Direction
def order: Parser[Direction] = {
"order" ~> "by" ~> ident ~ ("asc" | "desc") ^^ {
case f ~ "asc" => Asc(f)
case f ~ "desc" => Desc(f)
}
}
//output: Desc("age")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment