C0casio45
C0casio45
PPrisma
Created by C0casio45 on 2/4/2025 in #help-and-questions
Many to two relation
Hey, I have these model
model a {
id String @id @default(cuid())
b1 b @relation(fields: [b1Id], references: [id]) <- ERR
b2 b @relation(fields: [b2Id], references: [id])

b1Id String
b2Id String
}
model b {
id String @id @default(cuid())
a1 a @relation(fields: [a1Id], references: [id])
a2 a @relation(fields: [a2Id], references: [id])

a1Id String
a2Id String
}
model a {
id String @id @default(cuid())
b1 b @relation(fields: [b1Id], references: [id]) <- ERR
b2 b @relation(fields: [b2Id], references: [id])

b1Id String
b2Id String
}
model b {
id String @id @default(cuid())
a1 a @relation(fields: [a1Id], references: [id])
a2 a @relation(fields: [a2Id], references: [id])

a1Id String
a2Id String
}
the ERR is
Error validating model "a": Ambiguous relation detected. The fields `b1` and `b2` in model `a` both refer to `b`. Please provide different relation names for them by adding `@relation(<name>).
Error validating model "a": Ambiguous relation detected. The fields `b1` and `b2` in model `a` both refer to `b`. Please provide different relation names for them by adding `@relation(<name>).
4 replies