mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-29 16:56:23 +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);
|
const pollId = await getPollIdFromAdminUrlId(input.urlId);
|
||||||
|
|
||||||
if (input.optionsToDelete && input.optionsToDelete.length > 0) {
|
if (input.optionsToDelete && input.optionsToDelete.length > 0) {
|
||||||
await prisma.option.deleteMany({
|
await prisma.$transaction([
|
||||||
where: {
|
prisma.option.deleteMany({
|
||||||
pollId,
|
where: {
|
||||||
id: {
|
pollId,
|
||||||
in: input.optionsToDelete,
|
id: {
|
||||||
|
in: input.optionsToDelete,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
});
|
prisma.vote.deleteMany({
|
||||||
|
where: {
|
||||||
|
optionId: {
|
||||||
|
in: input.optionsToDelete,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.optionsToAdd && input.optionsToAdd.length > 0) {
|
if (input.optionsToAdd && input.optionsToAdd.length > 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue