feat(backend): add follow/unfollow endpoints and live follower counts
This commit is contained in:
1 parent
0778f188bc
commit
27174bef18
2 files changed
+33
-3
No files matched your search
@@ -28,10 +28,17 @@ export class PostsService {
|
||||
},
|
||||
},
|
||||
author: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
select: {
|
||||
name: true,
|
||||
_count: {
|
||||
select: {
|
||||
followers: true,
|
||||
following: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
} as const;
|
||||
|
||||
// Sichtbarkeit
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
async getUserProfile(userId: number) {
|
||||
const [user, followersCount, followingCount] = await Promise.all([
|
||||
this.prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
}),
|
||||
this.prisma.follow.count({
|
||||
where: { followingId: userId },
|
||||
}),
|
||||
this.prisma.follow.count({
|
||||
where: { followerId: userId },
|
||||
}),
|
||||
]);
|
||||
|
||||
return {
|
||||
...user,
|
||||
followersCount,
|
||||
followingCount,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user