diff options
author | Freya Murphy <freya@freyacat.org> | 2024-03-30 16:36:54 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-03-30 16:36:54 -0400 |
commit | 1f647374a8cdf3bc5c2d29ff8be277b027925c8c (patch) | |
tree | 9fdf42d250edb941de13ecd1aab9185ba2b30b00 /db/rest/post/api_post.sql | |
parent | rename views to _views (diff) | |
download | xssbook2-1f647374a8cdf3bc5c2d29ff8be277b027925c8c.tar.gz xssbook2-1f647374a8cdf3bc5c2d29ff8be277b027925c8c.tar.bz2 xssbook2-1f647374a8cdf3bc5c2d29ff8be277b027925c8c.zip |
post comments, refactor post loading, hide load more btn
Diffstat (limited to 'db/rest/post/api_post.sql')
-rw-r--r-- | db/rest/post/api_post.sql | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/db/rest/post/api_post.sql b/db/rest/post/api_post.sql index b49289c..375f292 100644 --- a/db/rest/post/api_post.sql +++ b/db/rest/post/api_post.sql @@ -3,10 +3,21 @@ CREATE VIEW api.post AS p.id, p.user_id, p.content, - p.date + p.date, + COALESCE(c.cc, 0) + AS comment_count FROM admin.post p - ORDER BY id DESC; + LEFT JOIN ( + SELECT + COUNT(c.id) as cc, + c.post_id + FROM + admin.comment c + GROUP BY + c.post_id + ) c ON p.id = c.post_id + ORDER BY p.id DESC; GRANT SELECT ON TABLE api.post TO rest_anon, rest_user; |