'Prisma - How to Make Variable Product Schema?

I want to make variable product schema in prisma, like woocommerce variable product.

this is my model, how can i make it for simple and variable product.



Solution 1:[1]

If I understand correctly you are trying to add attributes to the product model.

For simple attributes like size, you could use enums:

enum Size {
  S
  M
}

model Product {
  id    String @id @default(cuid())
  sizes Size[]
}

If you want to carry additional info with your attributes, you should create new model and relations:

model Size {
  id        String    @id @default(cuid())
  name      String
  createdAt DateTime  @default(now())
  products  Product[]
}

model Product {
  id    String @id @default(cuid())
  sizes Size[]
}

Solution 2:[2]

A similar question already has been answered here.

VS Code Python 3 doesn't actually create text file but it can still read from it

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ironolife
Solution 2