While I understand that the where clause in Prisma requires a unique input for its delete operation, I have utilized the @@unique function to ensure that multiple conditions need to be columns together and must be unique. However, I am struggling with how to implement this functionality when it comes to deleting data.
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])
}
try {
prisma.commentLike.delete({
where: {
user_id: user_id,
comment_id: comment_id,
}
})
} catch (e: any) {
console.log(e)
}
This method is not effective in achieving my goal. I attempted to use the AND clause as well, but unfortunately, that did not work either.