小编Al *_*ain的帖子

PrismaClientValidationError:无效的 `prisma.user.create()` 调用:

我正在尝试使用 Next.js 和 Prisma 创建一个 API。我有两个模型用户和个人资料。我想使用邮递员从 req.body 创建用户和配置文件字段。

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({ …
Run Code Online (Sandbox Code Playgroud)

rest node.js next.js prisma

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

next.js ×1

node.js ×1

prisma ×1

rest ×1