所以我理解Prisma中的where子句需要一个 unique 输入来运行它的delete,但是我已经使用了@@unique函数来确保 multiple 条件需要是唯一的。我正在努力理解的是当涉及到删除功能时如何实现这一点。
model CommentDislike {
id Int @id @default(autoincrement())
comment Comment @relation(fields: [comment_id], references: [id], onDelete: Cascade)
comment_id Int
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
user_id String
created_at DateTime @default(now())
@@unique([user_id, comment_id])
}
个字符
这不起作用。想使用AND子句,但这也不起作用。
1条答案
按热度按时间tquggr8v1#
如果你有一个复合id,你可以通过提供两者来删除,如下所述:https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-composite-ids-and-constraints#deleting-records-by-a-compound-id-or-unique-constraint
字符串