Skip to content

Instantly share code, notes, and snippets.

@sadache
Created February 28, 2011 22:27
Show Gist options
  • Save sadache/848179 to your computer and use it in GitHub Desktop.
Save sadache/848179 to your computer and use it in GitHub Desktop.
private val postWithAuthor = Post ~< User
def allWithAuthor : List[Post ~ User] =
SQL("""select * from Post p
join User u on p.author_id = u.id """)
.as(postWithAuthor*)
def byIdWithAuthorAndComments(id: Long) :
Option[Post ~ User ~ List[Comment]] = {
SQL("""select * from Post p
join User u on p.author_id = u.id
left join Comment c on c.post_id = p.id
where p.id = {id}""")
.on("id" -> id)
.as((postWithAuthor ~< (Comment*))?)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment