Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
1 reply
4b47

Help with new trpc syntax

Hello! Can anyone help me rewrite this example piece of code to new trpc syntax with Public procedures, so I will know how to do it? Thanks!:)

export const trainingRouter = createRouter()
    .mutation('createTraining', {
        input: z.object({
            trainingName: z.string(),
        }),
        async resolve({ input, ctx }) {
            const newlyCreatedTraining = await ctx.prisma.training.create({
                data: input,
            })
            return newlyCreatedTraining.id
        },
    })
Was this page helpful?