How would I achieve multple relations linked to th...
# orm-help
j
How would I achieve multple relations linked to the same column for user? For example, an author to something is linked to the users table by a one-to-one where it is owned and also linked by one-to-many where the item has multiple likes from users.
Copy code
model User {
  id        Int     @id @default(autoincrement())
  firstname String
  lastname  String
  username  String  @unique
  email     String  @unique
  password  String
  tel       String?
  country   String?
  bio       String?
  mealIds   Meal[]
}

model Meal {
  id    Int    @id @default(autoincrement())
  name  String @unique
  about String

  Owner        User  @relation(fields: [ownerId, likedUserIds], references: id) <--- Prisma does not like this
  ownerId      Int
  likedUserIds Int[]
}
1
n
It seems you are looking for Disambiguating relations. Can you have a look?
j
Oh I think that's it!! Prisma generated fine will report back 😁