feat: add likes

+ add ability for user to like a posts
+ add ability for user ot remove a like
+ add display of reply and like count
This commit is contained in:
Stevan Freeborn
2023-09-14 23:02:47 -05:00
parent 9cc9077017
commit 40515b3099
8 changed files with 161 additions and 12 deletions
+12
View File
@@ -135,3 +135,15 @@ export const getRepliesByParentId = query({
return { ...replies, page: repliesWithUserData };
},
});
export const getPostReplyCount = query({
args: { postId: v.id('posts') },
handler: async (ctx, args) => {
const replies = await ctx.db
.query('posts')
.withIndex('by_parent_id', q => q.eq('parentPostId', args.postId))
.collect();
return replies.length;
},
});