我正在尝试在Prisma ORM的一个模型中创建两个1:1关系,但是遇到以下错误:
验证模型“Person”时出错:检测到不明确的关系。模型“Person”中的字段
placeOfBirth
和placeOfDeath
都引用了Place
。请通过添加@relation(<name>)
为它们提供不同的关系名称。
我的prisma架构:
model Place {
id Int @id @default(autoincrement())
name String
persons Person[]
}
model Person {
id Int @id @default(autoincrement())
name String
placeOfBirthId Int
placeOfDeathId Int
placeOfBirth Place @relation(fields: [placeOfBirthId], references: [id])
placeOfDeath Place @relation(fields: [placeOfDeathId], references: [id])
}
完全不理解。
@relation("Births")
在Place
中就是我所遗漏的。谢谢!! - RaphaMex