I've got multiple procedures that need to share logic. For example, I've got a query and a mutation that both return a
lastUpdatedBy
lastUpdatedBy
field. Instead of returning the user id, I return their name. Technically, I've been able to write the code within both the query and mutation, but I'm struggling to find a way to share that logic.
The main issue is really a Typescript one where I can't figure out how to
getSomething: protectedProcedure .input(z.object({ id: z.string() })) .query(async ({ ctx, input }) => { let something = await ctx.db.somethings.findUnique({ where: { id: parseInt(input.id), }, }); // here's where I want to write some shared logic something = await processSomething({ something, db: ctx.db });
getSomething: protectedProcedure .input(z.object({ id: z.string() })) .query(async ({ ctx, input }) => { let something = await ctx.db.somethings.findUnique({ where: { id: parseInt(input.id), }, }); // here's where I want to write some shared logic something = await processSomething({ something, db: ctx.db });
The challenge I'm stuck on is figuring out the types in my util. I was able to get the prisma types, but not the