Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Fix can’t delete user with deleted polls (#1405)

Luke Vella82eb076c7145
diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.ts
index d53f5ce6c..c6aa6b83f 100644
--- a/apps/web/src/trpc/routers/polls.ts
+++ b/apps/web/src/trpc/routers/polls.ts
@@ -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: [
diff --git a/apps/web/src/trpc/routers/user.ts b/apps/web/src/trpc/routers/user.ts
index 1a3b426fc..cc34542b5 100644
--- a/apps/web/src/trpc/routers/user.ts
+++ b/apps/web/src/trpc/routers/user.ts
@@ -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);
diff --git a/packages/database/index.ts b/packages/database/index.ts
index a18895cbe..7ddafdec1 100644
--- a/packages/database/index.ts
+++ b/packages/database/index.ts
@@ -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>;