mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-28 17:56:37 +02:00
🐛 Fix can’t delete user with deleted polls
This commit is contained in:
parent
501cdd2b56
commit
c8cb3b3855
3 changed files with 6 additions and 14 deletions
|
@ -70,6 +70,7 @@ export const polls = router({
|
|||
return await prisma.poll.findMany({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
deleted: false,
|
||||
status: input.status === "all" ? undefined : input.status,
|
||||
},
|
||||
orderBy: [
|
||||
|
@ -110,6 +111,7 @@ export const polls = router({
|
|||
const polls = await prisma.poll.findMany({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
deleted: false,
|
||||
status: status === "all" ? undefined : status,
|
||||
},
|
||||
orderBy: [
|
||||
|
|
|
@ -56,7 +56,9 @@ export const user = router({
|
|||
await prisma.$transaction(async (tx) => {
|
||||
const polls = await tx.poll.findMany({
|
||||
select: { id: true },
|
||||
where: { userId: ctx.user.id },
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
},
|
||||
});
|
||||
const pollIds = polls.map((poll) => poll.id);
|
||||
|
||||
|
|
|
@ -3,19 +3,7 @@ import { PrismaClient } from "@prisma/client";
|
|||
export type * from "@prisma/client";
|
||||
|
||||
const prismaClientSingleton = () => {
|
||||
return new PrismaClient().$extends({
|
||||
query: {
|
||||
poll: {
|
||||
findMany: ({ args, query }) => {
|
||||
if (!args.where?.deleted) {
|
||||
args.where = { ...args.where, deleted: false };
|
||||
}
|
||||
|
||||
return query(args);
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
return new PrismaClient();
|
||||
};
|
||||
|
||||
export type ExtendedPrismaClient = ReturnType<typeof prismaClientSingleton>;
|
||||
|
|
Loading…
Add table
Reference in a new issue