.select({
id: comments.id,
parentId: comments.parentId,
// TODO countReplies: get the comment count where this id is listed as the parentId of other comments
(
SELECT COUNT(*)
FROM comments AS childComments
WHERE childComments.parentId = comments.id
) AS countReplies
})
.from(comments);
.select({
id: comments.id,
parentId: comments.parentId,
// TODO countReplies: get the comment count where this id is listed as the parentId of other comments
(
SELECT COUNT(*)
FROM comments AS childComments
WHERE childComments.parentId = comments.id
) AS countReplies
})
.from(comments);