heh guys, i have model like this ```model User {  ...
# orm-help
t
heh guys, i have model like this
Copy code
model User {
  id      String    @id
  email   String?   @unique
  profile Profile?
  product Product[]
  role    ROLE      @default(USER)
  orders   Order[]
}

model Order {
  id      Int          @id @default(autoincrement())
  buyerId String
  buyer   User         @relation(fields: [buyerId], references: [id])
  status  ORDER_STATUS
  seller  User         @relation(fields: [sellerId], references: [id])
}
User can be seller or buyer however this is giving me error
n
Heya again 🙂 you can use this schema:
Copy code
model User {
  id             String  @id
  email          String? @unique
  ordersAsBuyer  Order[] @relation("ordersAsBuyer")
  ordersAsSeller Order[] @relation("ordersAsSeller")

}

model Order {
  id       Int    @id @default(autoincrement())
  buyerId  String
  buyer    User   @relation(name: "ordersAsBuyer", fields: [buyerId], references: [id])
  sellerId String
  seller   User   @relation(name: "ordersAsSeller", fields: [sellerId], references: [id])
}
Note that because you have two relations, you have to add the relations fields twice per model and provide a
name
via the
@relation
attribute so that the relation can be disambiguated!
(Also, it would be great if you could use Slack's thread feature when writing multiple messages to keep the main channel a bit cleaner 😄 🙏)
t
sorry for that, i will keep that in mind, thank you very much
🙌 1
n
No problem! Did my suggestion solve your issue? 🙂
t
ya, it works, thank you
👌 1