fcsc_ipi_backend/app/models/product.model.js

61 lines
1.3 KiB
JavaScript

module.exports = (sequelize, DataTypes) => {
const Product = sequelize.define("products", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true,
},
product_name: {
type: DataTypes.STRING,
allowNull: false,
},
hs_code: {
type: DataTypes.STRING,
allowNull: true,
},
hs_description: {
type: DataTypes.TEXT,
allowNull: true,
},
is_active: {
type: DataTypes.BOOLEAN,
defaultValue: true,
},
created_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
},
created_by: {
type: DataTypes.INTEGER,
allowNull: true,
},
updated_at: {
type: DataTypes.DATE,
allowNull: true,
},
updated_by: {
type: DataTypes.INTEGER,
allowNull: true,
},
}, {
tableName: "products",
timestamps: false,
});
Product.associate = (models) => {
Product.hasMany(models.EstablishmentProduct, {
foreignKey: "product_id",
as: "establishment_products",
});
};
Product.associate = (models) => {
Product.hasMany(models.SubmissionProduct, {
foreignKey: "product_id",
as: "submission_products",
});
};
return Product;
};