未知参数“用户名”。可用选项标有?

问题描述 投票:0回答:1

我收到此错误:

Unknown argument 'username'. Available options are marked with ?.

我正在尝试为用户创建一个新的数据库条目,但不断收到相同的错误,

我正在使用 prisma、PostgreSQL 和 next.js。

我做错了什么?

这是我的

schema.prisma
文件:

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 {
  ...
}

这是我的创建用户功能

const newUser = await prisma.user.create({
        data: {
            clerkUserId: "test_id",
            email: "[email protected]",
            firstName: "test",
            lastName: "test,
            username: "testuser",
        },
    });

这是我得到的错误

⨯ 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'
}

我尝试跑步

prisma generate
prisma db pull
prisma migrate dev

postgresql next.js prisma plumatic-schema
1个回答
0
投票

要应用生成的迁移文件,请使用

prisma migrate deploy
,或将架构更改直接推送到数据库(对于开发人员)
prisma db push

© www.soinside.com 2019 - 2024. All rights reserved.