DEV Community

Discussion on: Prisma ORM update explicit many to many relations

Collapse
 
gdevtech profile image
Jesus Guzman

Here is what worked for me

return await ctx.prisma.product.update({
        where: {
          id: input.id,
        },
        data: {
          categories: {
            create: [
              {
                category: {
                  create: {
                    name: input.name,
                  },
                },
              },
            ],
          },
        },
      });
Enter fullscreen mode Exit fullscreen mode