How to return multiple prisma calls with trpc
how do i return two prisma calls
i tried this but did not work either
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,
},
},
},
});
}),
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,
},
},
},
});
}),
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,
},
},
},
});
}
}),
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,
},
},
},
});
}
}),
2 Replies