So I understand that the where clause in Prisma needs a unique input in order to run its delete, but I have used the @@unique function to ensure that multiple conditions need to be columns together need to be unique. What I am struggling to understand is how to implement this when it comes to the delete functionality.
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 does not work. Wanted to use the AND clause, but this does not work either.