Created
June 17, 2014 11:06
-
-
Save Deepwalker/0dcf2849ca4317638033 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
SELECT array_to_json(array_agg(row_to_json(t))) | |
FROM | |
(SELECT id, text, Cast(created_at AS text), | |
likes_count, | |
CASE | |
WHEN l.value THEN TRUE | |
ELSE FALSE | |
END AS liked | |
FROM posts | |
LEFT OUTER JOIN | |
(SELECT post_id, | |
TRUE AS value | |
FROM likes | |
WHERE user_id = 1) AS l ON l.post_id = posts.id LIMIT 100) AS t; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment