How can I update a user with a certain id connecti...
# orm-help
z
How can I update a user with a certain id connecting to an existing tag in a many-to-many relationship? https://www.prisma.io/docs/concepts/components/prisma-schema/relations/many-to-many-relations
Copy code
prisma.user.update({
    where: { id: '' },
    data: {
      name: 'John Doe',
      tags: {
        connect: {
          tagId_userId: {
            tagId: '',
            userId: ''
          }
        }
      }
    }
  })
I didn't want to repeat the
userId
especially because I'm going to be asking as an input for the user. Is there another way of doing that? In resume, is there a way to only specify the tag ids instead of the
userId
over and over again?
c
I think you just want to connect an array of tag IDs i.e.
Copy code
prisma.user.update({
    where: { id: '' },
    data: {
      name: 'John Doe',
      tags: {
        connect: [
          {
            id: ''
          },
          {
            id: ''
          }
        ]
      }
    }
  })
Disclaimer: wrote that from memory.