```Hello everyone Hereby I am stuck at one place ...
# orm-help
v
Copy code
Hello everyone

Hereby I am stuck at one place 

there is 1 model like below

model Channel {
  user_id       Int
  user          User           @relation("user_channels", fields: [user_id], references: [id])
  provider_id   Int
  provider      User           @relation("provider_channels", fields: [provider_id], references: [id])
  created_at    DateTime       @default(now())
  updated_at    DateTime       @updatedAt
  deleted_at    DateTime?
  conversations Conversation[]

  @@id([user_id, provider_id], name: "user_provider_id")
  @@map("channels")
}

now there is a model named Conversation

Conversation {
 channel_id Int
 channel  @relation(fields: [channel_id], references: [id])
...
}

But I am not getting what to write or define relation here as there is no id in channel id

have any idea ?

thank you
✅ 1
l
the
id
of the Channel model is
user_provider_id
as defined in the
@@id
. I've not tested if prisma can create relationships to an Composite ID, but if so then it would just be:
Copy code
Conversation {
 channel_id Int
 channel  @relation(fields: [channel_id], references: [user_provider_id])
...
}
v
thanks but i tried that but not working
l
then i would assume that you need to have an explicit ID on the Channel model. Could just be an auto generated int or UUID.
v
ok thanks That is the way I am doing right now. I thought, this may be the better approach, so just trying/optimizing the way of db structure.