PrismaP
Prisma8mo ago
3 replies
Markigno

multiple relation with same field

let's assume i want to use the same field to create a relation to different tables, is it possible?
I'm thinking something like this

LinkTable{
id String @id @default(uuid())
idLink String
linkedTable String //this will assume value "TABLE1" or "TABLE2"
table1 Table1 @relation(fields: [linkedTable ], references: [id])
table2 Table2 @relation(fields: [linkedTable ], references: [id])
}

Table1{
id String @id @default(uuid())
...
}

Table2{
id String @id @default(uuid())
}
Was this page helpful?