mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-28 08:16:22 +02:00
🐛 Votes for deleted option should be deleted
This commit is contained in:
parent
f2ae4d6465
commit
de2ebf567a
1 changed files with 16 additions and 7 deletions
|
@ -165,14 +165,23 @@ export const polls = router({
|
|||
const pollId = await getPollIdFromAdminUrlId(input.urlId);
|
||||
|
||||
if (input.optionsToDelete && input.optionsToDelete.length > 0) {
|
||||
await prisma.option.deleteMany({
|
||||
where: {
|
||||
pollId,
|
||||
id: {
|
||||
in: input.optionsToDelete,
|
||||
await prisma.$transaction([
|
||||
prisma.option.deleteMany({
|
||||
where: {
|
||||
pollId,
|
||||
id: {
|
||||
in: input.optionsToDelete,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}),
|
||||
prisma.vote.deleteMany({
|
||||
where: {
|
||||
optionId: {
|
||||
in: input.optionsToDelete,
|
||||
},
|
||||
},
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
if (input.optionsToAdd && input.optionsToAdd.length > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue