Next.js Discord

Discord Forum

Make a "group by" Prisma request

Unanswered
Upland Sandpiper posted this in #help-forum
Open in Discord
Upland SandpiperOP
Hello.

Here are my Prisma models :

model ProductType {
  id      Int      @id @default(autoincrement())
  name    String
  slug    String   @unique
  products Product[]
}

model Product {
  id           Int          @id @default(autoincrement())
  name         String
  slug         String       @unique
  description  String
  price        Float
  typeId       Int
  type         ProductType  @relation(fields: [typeId], references: [id])
  submodeleId  Int
  submodele    SubModele    @relation(fields: [submodeleId], references: [id])

  @@unique([slug, submodeleId]) 
  @@index([submodeleId]) 
  @@index([typeId]) 
}


I would like to make a prisma request to get products group by type of product. Can you help me ?

0 Replies