Hello i have this error, i want to get a user with...
# orm-help
s
Hello i have this error, i want to get a user with specific role Id but i don't understand why i have this Controller :
Copy code
@Get('getCoiffeurs')
async getCoiffeurs(@Param('roleId') roleId: string): Promise<User> {
  return await this.usersService.findAllCoiffeurs({ roleId: roleId });
}
Service :
Copy code
async findAllCoiffeurs(
  userWhereUniqueInput: Prisma.UserWhereUniqueInput,
): Promise<User | null> {
  return this.prismaService.user.findUnique({
    where: {
      roleId: userWhereUniqueInput?.roleId,
    },
  });
}
r
@Simoh 2k 👋 You need
findFirst
here instead of
findUnique
.
findUnique
is only for unique fields in the model.
s
Thank's Ryan !
👍 1