2019-06-13 07:53:57 +00:00
|
|
|
module.exports = function (sequelize, DataTypes) {
|
2022-02-18 19:32:30 +00:00
|
|
|
const Rol = sequelize.define(
|
|
|
|
|
"Rol",
|
|
|
|
|
{
|
|
|
|
|
id: {
|
|
|
|
|
type: DataTypes.UUID,
|
|
|
|
|
defaultValue: DataTypes.UUIDV4,
|
|
|
|
|
primaryKey: true,
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
|
allowNull: false,
|
|
|
|
|
unique: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
tableName: "roles",
|
|
|
|
|
freezeTableName: true,
|
|
|
|
|
timestamps: true,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
Rol.associate = function (models) {
|
|
|
|
|
Rol.Users = Rol.belongsToMany(models.User, {
|
|
|
|
|
through: models.UserRoles,
|
|
|
|
|
foreignKey: "rolId",
|
2019-06-13 07:53:57 +00:00
|
|
|
});
|
2022-02-18 19:32:30 +00:00
|
|
|
};
|
|
|
|
|
return Rol;
|
2019-06-13 07:53:57 +00:00
|
|
|
};
|