import {Model, DataTypes} from 'sequelize'; import {CategoriesModel,StoreModel} from './models'; import {sequelize} from './Connection'; interface AttrCategoriesInterface extends Model { id: number; name: string; value: string, category_id: number; store_id: number; } const AttrCategoriesModel = sequelize.define('AttrCategories', { id: { type: DataTypes.INTEGER.UNSIGNED, autoIncrement: true, primaryKey: true, }, name: { type: new DataTypes.STRING(100), allowNull: false, }, value: { type: new DataTypes.STRING(100), allowNull: false, }, category_id: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, references: { model: CategoriesModel, key: 'id' }, onDelete: 'CASCADE', }, store_id: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, references: { model: StoreModel, key: 'id' }, onDelete: 'CASCADE', } }, { tableName: 'tb_attr_categories', freezeTableName: true, timestamps: true, underscored: true, name:{ singular: 'AttrCategories', plural: 'AttrCategories' }, } ); export {AttrCategoriesModel , AttrCategoriesInterface};