summaryrefslogtreecommitdiff
path: root/src/db/rest/post
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/rest/post')
-rw-r--r--src/db/rest/post/api_post.sql15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/db/rest/post/api_post.sql b/src/db/rest/post/api_post.sql
index 0d60473..b5c42a8 100644
--- a/src/db/rest/post/api_post.sql
+++ b/src/db/rest/post/api_post.sql
@@ -6,7 +6,9 @@ CREATE VIEW api.post AS
p.created,
p.modified,
COALESCE(c.cc, 0)
- AS comment_count
+ AS comment_count,
+ COALESCE(l.lc, 0)
+ AS like_count
FROM
admin.post p
LEFT JOIN (
@@ -20,6 +22,17 @@ CREATE VIEW api.post AS
) c
ON
p.id = c.post_id
+ LEFT JOIN (
+ SELECT
+ COUNT(l.id) as lc,
+ l.post_id
+ FROM
+ admin.like l
+ GROUP BY
+ l.post_id
+ ) l
+ ON
+ p.id = l.post_id
LEFT JOIN
admin.user u
ON