mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-01 02:01:48 +02:00
Delete votes first
This commit is contained in:
parent
13e99a9594
commit
f7400f5aad
1 changed files with 5 additions and 7 deletions
|
@ -59,9 +59,13 @@ export const user = router({
|
|||
where: { userId: ctx.user.id },
|
||||
});
|
||||
const pollIds = polls.map((poll) => poll.id);
|
||||
await tx.comment.deleteMany({
|
||||
|
||||
await tx.vote.deleteMany({
|
||||
where: { pollId: { in: pollIds } },
|
||||
});
|
||||
await tx.comment.deleteMany({
|
||||
where: { OR: [{ pollId: { in: pollIds } }, { userId: ctx.user.id }] },
|
||||
});
|
||||
await tx.option.deleteMany({
|
||||
where: { pollId: { in: pollIds } },
|
||||
});
|
||||
|
@ -71,15 +75,9 @@ export const user = router({
|
|||
await tx.watcher.deleteMany({
|
||||
where: { OR: [{ pollId: { in: pollIds } }, { userId: ctx.user.id }] },
|
||||
});
|
||||
await tx.vote.deleteMany({
|
||||
where: { pollId: { in: pollIds } },
|
||||
});
|
||||
await tx.event.deleteMany({
|
||||
where: { userId: ctx.user.id },
|
||||
});
|
||||
await tx.comment.deleteMany({
|
||||
where: { OR: [{ pollId: { in: pollIds } }, { userId: ctx.user.id }] },
|
||||
});
|
||||
await tx.poll.deleteMany({
|
||||
where: { userId: ctx.user.id },
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue