我正在尝试更新 Prisma 中的一对多关系。我的架构看起来像这样
model A_User {
id Int @id
username String
age Int
bio String @db.VarChar(1000)
createdOn DateTime @default(now())
features A_Features[]
}
model A_Features {
id Int @id @default(autoincrement())
description String
A_User A_User? @relation(fields: [a_UserId], references: [id])
a_UserId Int?
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试向 id: 1 的用户添加一些新功能,或者更新它们(如果它们已经存在)。
我正在尝试做类似的事情
const post = await prisma.a_User.update({
where: { id: 1},
data: {
features: {
upsert: [
{ description: 'first feature'},
{ description: 'second feature'}
]
}
}
})
Run Code Online (Sandbox Code Playgroud)
编译器不高兴,它告诉我
Type '{ features: { upsert: { description: …Run Code Online (Sandbox Code Playgroud)