Javascript Prisma更新功能因类型不正确而失败
我用的是Prisma2。变异函数如下所示:Javascript Prisma更新功能因类型不正确而失败,javascript,database,prisma,mutation,prisma2,Javascript,Database,Prisma,Mutation,Prisma2,我用的是Prisma2。变异函数如下所示: const updateUserProfileDetails = async ( inputValues, ctx: { session?: SessionContext } = {} ) => { const profile = await db.user.update({ where: { id: ctx.session!.userId }, data: { profile: { updat
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;
};
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
}
然而,在关于我、位置
、专业
道具的上,typescript却在尖叫:
类型“string”不可分配给类型“NullableStringFieldUpdateOperationsInput |未定义”。ts(2322)
相关架构如下所示:
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;
};
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在这里没有抱怨,查询也很好