"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const sequelize_1=require("sequelize");class role extends sequelize_1.Model{static initModel(e){return role.init({id:{type:sequelize_1.DataTypes.INTEGER,autoIncrement:!0,primaryKey:!0,allowNull:!1},name:{type:sequelize_1.DataTypes.STRING(255),allowNull:!1,unique:"roleNameKey",validate:{notEmpty:{msg:"name: Name cannot be empty"}},comment:"Unique name of the role (e.g., Admin, User, Moderator)"}},{sequelize:e,modelName:"role",tableName:"role",timestamps:!1,indexes:[{name:"PRIMARY",unique:!0,using:"BTREE",fields:[{name:"id"}]},{name:"roleNameKey",unique:!0,using:"BTREE",fields:[{name:"name"}]}]})}static associate(e){this.belongsToMany(e.permission,{through:e.rolePermission,as:"permissions",foreignKey:"roleId",otherKey:"permissionId",onDelete:"CASCADE",onUpdate:"CASCADE"});this.hasMany(e.user,{as:"users",foreignKey:"roleId",onDelete:"CASCADE",onUpdate:"CASCADE"})}}exports.default=role;