Skip to content

Commit e735c79

Browse files
authored
Merge pull request #5 from neerajsde/neeraj
Neeraj
2 parents caf31a3 + f71edb9 commit e735c79

13 files changed

Lines changed: 536 additions & 151 deletions

prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ model CommentLike {
654654
post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
655655
comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade)
656656
657-
@@id([userId, postId])
657+
@@id([userId, commentId])
658658
}
659659

660660
model Follow {

scratch-test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { PrismaClient } from '@prisma/client';
2+
const prisma = new PrismaClient();
3+
4+
async function main() {
5+
const user = await prisma.user.findFirst();
6+
console.log("User:", user?.id);
7+
if (!user) return;
8+
9+
const post = await prisma.post.findFirst({
10+
where: { likes: { some: { userId: user.id, isLiked: true } } },
11+
include: { likes: { where: { userId: user.id } } }
12+
});
13+
console.log("Liked Post:", post?.id, post?.likes);
14+
15+
if (post) {
16+
const postSelect = {
17+
likes: {
18+
where: { userId: user.id, isLiked: true },
19+
select: { userId: true },
20+
take: 1,
21+
}
22+
};
23+
const feed = await prisma.post.findUnique({
24+
where: { id: post.id },
25+
select: postSelect
26+
});
27+
console.log("Feed Output:", JSON.stringify(feed, null, 2));
28+
}
29+
}
30+
main();

src/constants/redisKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const REDIS_KEYS = {
2626
postData: (postId: string) => `post:data:${postId}`,
2727
postComments: (postId: string, page: number, limit: number) => `post:comments:${postId}:${page}:${limit}`,
2828
postCommentsPattern: (postId: string) => `post:comments:${postId}:*`,
29+
commentReplies: (commentId: string, page: number, limit: number) => `comment:replies:${commentId}:${page}:${limit}`,
2930
// dashboard data cache
3031
dashboardStats: () => `dashboard:stats:users`,
3132
dashboardGrowth: () => `dashboard:growth:users`,

0 commit comments

Comments
 (0)