Hi everyone! I have two tables connected via *expl...
# orm-help
e
Hi everyone! I have two tables connected via explicit many-to-many relationships: Posts and Tags. I'm trying to update a list of Tags for a particular Post, but it removes all tags from other posts. What am I doing wrong? My query is:
Copy code
prisma.post.update({
  data: {
    tags: [{
      create: {
        author: {
          connect: {
            id: authorId
          }
        },
        tag: {
          connect: {
            id: tagId
          }
        }
      }
    }] 
  },
  where: {
    id: postId
  }
})
1
m
What is this query supposed to do? Also post your schema please.
e
Sorry, that was a dumb mistake. I delete all tags beforehand and I passed
undefined
to where clause. So it was
Copy code
await prisma.tagsOnPosts.deleteMany({
  where: {
    postId: undefined
  }
})
that's why it removed all tags from other posts 😞