Hey folks, anyone able to help me properly model: ...
# orm-help
s
Hey folks, anyone able to help me properly model:
Copy code
model Item {
  id String @unique
}

model Set {
  additions Item[]
  removals Item[]
}
I can’t get the right combination of references and stuff between the two
n
Hey 👋 From the schema that you have mentioned, it seems you need to have multiple relations between two same models
Copy code
model Item {
  id            String  @id @default(uuid())
  additionSet   Set?    @relation(name: "ADDITION_SET", fields: [additionSetId], references: [id])
  additionSetId String?
  removalSet    Set?    @relation(name: "REMOVAL_SET", fields: [removalSetId], references: [id])
  removalSetId  String?
}

model Set {
  id        String @id @default(uuid())
  additions Item[] @relation("ADDITION_SET")
  removals  Item[] @relation("REMOVAL_SET")
}
Can you have a look at this schema and see if it solves it for you? You probably are looking for Disambiguating Relations
💯 1
s
hey @Nurul that’s great thanks, got me in the right direction. It’s a m-to-m relationship to I added @id to both models and changed the
Set?
to
Set[]
and after removing
fields:
it seems to work, thanks!
👍 1
n
Great! I wasn’t sure about what relationship was there between the models but glad to know that it’s working now
s
Yeah no prob, appreciate it 🙂
o
Como vocês fazem para enviar o código formatado no Slack? Tentei com backticks mas não deu certo?
n
You need to use three backticks to format the code
o
Ok. Muito obrigado.