mirror of
https://github.com/hknsh/project-knedita.git
synced 2024-11-28 17:41:15 +00:00
feat: updated fetch-info
updated fetch-info to return user's followers and following
This commit is contained in:
parent
fe904c26c9
commit
2ad6018806
1 changed files with 13 additions and 1 deletions
|
@ -8,10 +8,13 @@ async function userFetchInfoService(
|
|||
username,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
profileImage: true,
|
||||
displayName: true,
|
||||
username: true,
|
||||
createdAt: true,
|
||||
followers: true,
|
||||
following: true,
|
||||
posts: {
|
||||
select: {
|
||||
id: true,
|
||||
|
@ -32,7 +35,16 @@ async function userFetchInfoService(
|
|||
return new Error('User not found')
|
||||
}
|
||||
|
||||
return user
|
||||
const followers = user.followers.length
|
||||
const following = user.following.length
|
||||
|
||||
const info = {
|
||||
...user,
|
||||
followers,
|
||||
following,
|
||||
}
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
export default userFetchInfoService
|
||||
|
|
Loading…
Reference in a new issue