Prisma, many to one relation its the same as many to many in prisma working with mongodb?

9 Views Asked by At
Prisma, many to one relation its the same as many to many in prisma working with mongodb?

example many to many

model User {
  id              String           @id @default(auto()) @map("_id") @db.ObjectId
  name            String
  lastname        String
  age             Int
  address         Address
  usercredentials UserCredentials?
  profilePhoto    String?
  subscription    Subscriptions[] @relation(fields: [subscriptionid], references: [id])
  subscriptionid String[] @db.ObjectId
}
model Subscriptions {
  id    String @id @default(auto()) @map("_id") @db.ObjectId
  users  User[] @relation(fields: [usersid],references: [id])
  usersid String[] @db.ObjectId
}

example many to one

`model User {
  id              String           @id @default(auto()) @map("_id") @db.ObjectId
  name            String
  lastname        String
  age             Int
  address         Address
  usercredentials UserCredentials?
  profilePhoto    String?
  subscription    Subscriptions @relation(fields: [subscriptionid], references: [id])
  subscriptionid String @db.ObjectId
}
model Subscriptions {
  id    String @id @default(auto()) @map("_id") @db.ObjectId
  users  User[] 
}`

user document subscriptionid : 25345453

subscription document id : 25345453 users [564654544,223342345,56346345]

0

There are 0 best solutions below