由于类型不正确,棱镜更新功能失败

问题描述

我正在使用Prisma2。变异函数如下所示:

const updateUserProfileDetails = async (
  inputValues,ctx: { session?: SessionContext } = {}
) => {
  const profile = await db.user.update({
    where: { id: ctx.session!.userId },data: {
      profile: {
        update: {
          aboutMe: "this is a random message for about me.",// type error is displayed here
          location: "London,UK",// same type error here
          profession: "rubber duck",// same type error here
        },},});
  return profile;
};

但是,在aboutMelocationprofession道具上,打字稿正在尖叫:

Type 'string' is not assignable to type 'NullableStringFieldUpdateOperationsInput | undefined'.ts(2322)

相关架构如下:

model User {
  id             Int       @default(autoincrement()) @id
  createdAt      DateTime  @default(now())
  updatedAt      DateTime  @updatedAt
  firstName      String?
  lastName       String?
  email          String    @unique
  hashedPassword String?
  role           String    @default("user")
  sessions       Session[]
  profile        Profile?
}

model Profile {
  id                 Int       @default(autoincrement()) @id
  aboutMe            String?
  location           String?
  profession         String?
  user               User      @relation(fields:[userId],references: [id])
  userId             Int
}

版本:

@prisma/cli: 2.6.0 => 2.6.0 
@prisma/client: 2.6.0 => 2.6.0 

我一直无法找到NullableStringFieldUpdateOperationsInput的定义(通过文件夹搜索)。我在做什么错了?

解决方法

能否将@prisma/cli@prisma/client更新为 2.7.1 ?它在最新版本中工作正常。我已经尝试过了,TS在这里没有抱怨,查询也可以正常工作。

TypeScript snippet

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...