Theo's Typesafe CultTTC
Theo's Typesafe Cult4y ago
4 replies
shu

How to return multiple prisma calls with trpc

how do i return two prisma calls
follow: protectedProcedure.input(z.object({ userid: z.string(), pageid: z.string() })).mutation(async ({ input, ctx }) => {
      ctx.prisma.user.update({
        where: {
          id: input.userid,
        },
        data: {
          following: {
            set: {
              id: input.pageid,
            },
          },
        },
      }),
        ctx.prisma.user.update({
          where: {
            id: input.pageid,
          },
          data: {
            followers: {
              set: {
                id: input.userid,
              },
            },
          },
        });
  }),

i tried this but did not work either
follow: protectedProcedure.input(z.object({ userid: z.string(), pageid: z.string() })).mutation(async ({ input, ctx }) => {
    return () => {
      ctx.prisma.user.update({
        where: {
          id: input.userid,
        },
        data: {
          following: {
            set: {
              id: input.pageid,
            },
          },
        },
      }),
        ctx.prisma.user.update({
          where: {
            id: input.pageid,
          },
          data: {
            followers: {
              set: {
                id: input.userid,
              },
            },
          },
        });
    }
  }),
Was this page helpful?