I am trying to create an API using Next.js & Prisma. I have two model user & profile. I want to create user & also profile field from req.body using postman.
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
name String
email String @unique
password String
profile Profile?
}
model Profile {
id Int @default(autoincrement()) @id
bio String?
user User @relation(fields: [userId], references: [id])
userId Int @unique
}
here my create function:
//Create User
let { name, email, password, } = req.body;
const createUser = await prisma.user.create({
data: {
name: name,
email: email,
password: user_password,
profile: {
create: { bio: 'Bsc' }
},
}
});
res.status(201).json({ error: false, msg: "User Create Successfuly" });
After URL hit I got an error.
PrismaClientValidationError: Invalid prisma.user.create()
invocation
Unknown arg profile
in data.profile for type UserCreateInput. Did you mean email
?
Available args:type UserCreateInput
How can I solve this?