mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-19 20:06:19 +02:00
45 lines
879 B
TypeScript
45 lines
879 B
TypeScript
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,
|
|
},
|
|
});
|
|
}),
|
|
});
|