mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-31 23:19:15 +02:00
⬆️ v3.0.0 (#704)
This commit is contained in:
parent
735056f25f
commit
c22b3abc4d
385 changed files with 19912 additions and 5250 deletions
45
packages/backend/trpc/routers/polls/options.ts
Normal file
45
packages/backend/trpc/routers/polls/options.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { prisma } from "@rallly/database";
|
||||
import { z } from "zod";
|
||||
|
||||
import { publicProcedure, router } from "../../trpc";
|
||||
|
||||
export const options = router({
|
||||
list: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
pollId: z.string(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ input: { pollId } }) => {
|
||||
const options = await prisma.option.findMany({
|
||||
where: {
|
||||
pollId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
start: true,
|
||||
duration: true,
|
||||
},
|
||||
orderBy: [
|
||||
{
|
||||
start: "asc",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return options;
|
||||
}),
|
||||
delete: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
optionId: z.string(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input: { optionId } }) => {
|
||||
await prisma.option.delete({
|
||||
where: {
|
||||
id: optionId,
|
||||
},
|
||||
});
|
||||
}),
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue