Created
April 18, 2011 17:00
-
-
Save sadache/925698 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 prevNext = { | |
SQL( | |
""" | |
( | |
select *, 'next' as pos from post | |
where postedAt < {date} order by postedAt desc limit 1 | |
) | |
union | |
( | |
select *, 'prev' as pos from post | |
where postedAt > {date} order by postedAt asc limit 1 | |
) | |
order by postedAt desc | |
""" | |
).on("date" -> postedAt).as( | |
opt('pos.is("prev")~>Post.on("")) ~ opt('pos.is("next")~>Post.on("")) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment