大家好,这是我的情况;
model User {
id Int @default(autoincrement()) @id
...
posts Post[]
comments Comment[]
}
model Post {
id Int @default(autoincrement()) @id
comments Comment[]
...
}
model Comment {
id Int @default(autoincrement()) @id
post Post @relation(fields: [postId], references: [id])
postId Int
...
}
所以我正在尝试删除评论,下面是我的方法
export const deleteComment = mutationField('deleteComment', {
type: 'Comment',
args: {
where: 'CommentWhereUniqueInput',
},
resolve: async (_, { where }, ctx) => {
let comment = await ctx.prisma.comment.delete({
where: where,
include:{
author: true,
post:true
},
})
return comment
},
})
但是我收到一条错误消息,上面写着“不能为不可为空的字段 Comment.post 返回 null。” 知道我该如何解决吗?谢谢