Reputation: 1
I get this error: Unknown argument 'username'. Available options are marked with ?.
I am trying to create a new DB entry for the user but keep getting the same error,
i am working with prisma, PostgreSQL and next.js.
what am I doing wrong?
This is my schema.prisma
file:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
email String @unique
firstName String?
lastName String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
clerkUserId String @unique
id Int @id @default(autoincrement())
username String @unique
createdQuestions Question[]
joinedQuestions Question[] @relation("Participants")
model Question {
...
}
This is my create user function
const newUser = await prisma.user.create({
data: {
clerkUserId: "test_id",
email: "[email protected]",
firstName: "test",
lastName: "test,
username: "testuser",
},
});
This is the error that i get
⨯ PrismaClientValidationError:
Invalid `prisma.user.create()` invocation:
{
data: {
clerkUserId: "test_id",
email: "[email protected]",
firstName: "test",
lastName: "test",
username: "testuser",
~~~~~~~~
? createdQuestions?: QuestionCreateNestedManyWithoutCreatorInput,
? joinedQuestions?: QuestionCreateNestedManyWithoutParticipantsInput
}
}
Unknown argument `username`. Available options are marked with ?.
at async GET (./app/api/test/route.ts:11:21)
⨯ TypeError: The "payload" argument must be of type object. Received null
at frame (node_modules\next\src\server\patch-error-inspect.ts:89:42)
...
at async Server.requestListener (node_modules\next\src\server\lib\start-server.ts:146:6) {
code: 'ERR_INVALID_ARG_TYPE',
page: '/api/test'
}
I tried to run prisma generate
prisma db pull
prisma migrate dev
Upvotes: 0
Views: 313
Reputation: 872
To apply the generated migration files use prisma migrate deploy
, or to push schema changes to db directly (for dev) prisma db push
Upvotes: 0