Hi, the doc says for implicit <Many-to-many relati...
# orm-help
l
Hi, the doc says for implicit Many-to-many relations the name of col must be named as
A
and
B
. Is there a way to name it meaningful? Or I have to construct it explicitly?
m
Think it has to be explicitly defined
l
Got the same setup by defining this:
Copy code
model PostToComment {
  post   Post @relation(fields: [postId], references: [id])
  postId Int    @map("post_id")

  comment   Comment @relation(fields: [commentId], references: [id])
  commentId Int             @map("comment_id")

  @@unique([postId, commentId])
  @@index([commentId])
  @@map("_PostToComment")
}
r
@Leo Li 👋 The above would be an explicit M-N relation. For implicit relations, you need to adhere to the conventions of
A
and
B
as the table names.
l
Thanks @Ryan, our team found A/B is too cryptic when people looking at the raw table directly. Would be curious to know if I setup explicitly like the above, would I miss any implicit convenience other than manually define it like the above?
r
There’s one convenience that you would miss i.e. if you’re adding relations, you would need to go an extra level to connect/create records as the relation table will be included in b/w due the explicit nature.
👍 1
l
Got it, cool!
👍 1