0

我正在使用 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;
};

然而,在aboutMe, location,profession道具上,打字稿在尖叫:

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

相关的 Schema 如下所示:

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,. 我究竟做错了什么?

4

1 回答 1

1

你能更新到@prisma/cli2.7.1?它在最新版本中运行良好。我已经尝试过了,TS 在这里没有抱怨,而且查询也可以正常工作。@prisma/client

打字稿片段

于 2020-09-29T11:25:06.133 回答