小编Nik*_*yov的帖子

无法在 Prisma 的一个模型中建立两个 1:1 关系。检测到不明确的关系

我试图在 Prisma ORM 的一个模型中建立两个 1:1 关系,但出现以下错误:

验证模型“Person”时出错:检测到不明确的关系。模型中的字段placeOfBirth和字段均指的是。请通过添加 为它们提供不同的关系名称。placeOfDeathPersonPlace@relation(<name>)

我的棱镜架构:

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])
}
Run Code Online (Sandbox Code Playgroud)

完全不明白。

orm schema database-schema prisma prisma2

16
推荐指数
1
解决办法
7338
查看次数

标签 统计

database-schema ×1

orm ×1

prisma ×1

prisma2 ×1

schema ×1