Skip to content

Commit

Permalink
refactor: Update UserService to only update name if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
PleBea committed Jul 13, 2024
1 parent 0f6f212 commit 138595f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export class UserService {
const user = await this.prisma.user.findUnique({ where: { id } });
if (!user) throw new HttpException('User not found', HttpStatus.NOT_FOUND);

await this.prisma.user.update({ where: { id }, data });
await this.prisma.user.update({
where: { id },
data: {
...(data.name ? { name: data.name } : {}),
},
});

return data;
}
Expand Down

0 comments on commit 138595f

Please sign in to comment.