I have a question about using Prisma with Nest. I keep encountering this error:
src/modules/auth/auth.service.ts:28:63 - error TS2322: Type 'UserWhereUniqueInput' is not assignable to type 'string'.
28 const user = await this.prisma.user.findUnique({ where: { email } });
~~~~~
node_modules/.prisma/client/index.d.ts:1521:5
1521 email?: string
~~~~~
The expected type comes from property 'email' which is declared here on type 'UserWhereUniqueInput'
[11:50:56 PM] Found 1 error. Watching for file changes
in auth.service.ts
...
@Injectable()
export class AuthService {
constructor(private jwtService: JwtService, private prisma: PrismaService) {}
async signIn({
email,
password,
}: {
email: Prisma.UserWhereUniqueInput;
password: string;
}) {
const user = await this.prisma.user.findUnique({ where: { email } });
...
This is my User schema:
model User {
id Int @id @default(autoincrement())
email String @unique
password String
lastName String?
firstName String?
roles String[]
}
The controller that's calling the service looks like this:
...
@Post('sign-in')
signIn(@Body() signinAuthDto: any) {
return this.authService.signIn(signinAuthDto);
}
Despite changing to SigninAuthDto, the issue persists:
export class SigninAuthDto {
email: string;
password: string;
}