A
A
Alexander2021-11-26 03:34:20
PostgreSQL
Alexander, 2021-11-26 03:34:20

How to implement Sizes model for products in sequelize?

61a02b271e0d9541824376.png
Please tell me how to implement the Sizes model for products in sequelize so that it is possible to change the presence of n sizes in the admin panel, how to model the table correctly?
I already have a sizes model that has all possible sizes, and a product_variant model that will be populated with values ​​from sizes. But the question is more about where to use the isAvailable: boolean value in order to implement what was intended. I'm currently using a many-to-many relationship.
I will be grateful for the answer

ProductModel.belongsToMany(Size, { through: ProductModelSize, onDelete: 'CASCADE' })
Size.belongsToMany(ProductModel, { through: ProductModelSize, onDelete: 'CASCADE' })

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question