import { DataTypes, Model, InferAttributes, InferCreationAttributes, CreationOptional, } from 'sequelize'; import { sequelize } from './index'; import { SettingInterface } from '../shared/interfaces/setting.interface'; import User from './users'; class Setting extends Model, InferCreationAttributes> implements SettingInterface { declare id: CreationOptional; declare setting_key: string; declare setting_value: string; declare updated_by: number; } Setting.init( { id: { type: DataTypes.INTEGER.UNSIGNED, autoIncrement: true, primaryKey: true, unique: true, }, setting_key: { type: DataTypes.STRING, allowNull: false, }, setting_value: { type: DataTypes.TEXT, allowNull: false, }, updated_by: { type: DataTypes.INTEGER, allowNull: false, references: { model: 'users', key: 'id', } }, }, { sequelize, tableName: 'settings', underscored: true, freezeTableName: true, timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at', } ); Setting.belongsTo(User, { foreignKey: 'updated_by' }); export default Setting;