I am trying to create Singup API in ExpressJS and Prisma.
I am checking whether given email exists in my database or not. When I pass the email and password, it throws Unknown arg email in where.email for type SignupWhereUniqueInput. Did you mean id? Available args: error.
I tried using select: { email: true, password: true } but its not working. Code is working only if I pass id number instead of email. Any ideas what is wrong here??
router.post(`/signup`, async (req, res) => {
const { email, password } = req.body;
const hashPassword = await bcrypt.hash(password, 10);
const checkEmail = await prisma.signup.findUnique({
where: {
email: email
}
});
if (checkEmail) {
return res.status(400).json({
error: "Pick different one"
});
}
const userSignUp = await prisma.signup.create({
data: {
email,
password: hashPassword
}
});
return res.json(userSignUp);
});
// DB Schema
model Signup {
id Int @id @default(autoincrement())
email String
password String
}