Vats Patel
07/29/2022, 8:59 AMHello 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 youLloyd Richards
07/29/2022, 9:22 AMid 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:
Conversation {
channel_id Int
channel @relation(fields: [channel_id], references: [user_provider_id])
...
}Vats Patel
07/29/2022, 9:28 AMLloyd Richards
07/29/2022, 9:31 AMVats Patel
07/29/2022, 9:34 AM