48 lines
1016 B
JavaScript
48 lines
1016 B
JavaScript
/**
|
|
* Copyright (c) 2026 Niolla
|
|
* All rights reserved.
|
|
*
|
|
* This source code is proprietary and confidential.
|
|
* Unauthorized copying, modification, distribution, or use
|
|
* of this file, via any medium, is strictly prohibited.
|
|
*/
|
|
|
|
// app/models/permission/rolePermission.model.js
|
|
|
|
module.exports = (sequelize, DataTypes) => {
|
|
const rolePermission = sequelize.define(
|
|
"rolePermission",
|
|
{
|
|
rp_id: {
|
|
type: DataTypes.STRING,
|
|
primaryKey: true
|
|
},
|
|
role_id: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false
|
|
},
|
|
permission_id: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false
|
|
}
|
|
},
|
|
{
|
|
tableName: "rolePermission",
|
|
timestamps: true
|
|
}
|
|
);
|
|
|
|
rolePermission.associate = (db) => {
|
|
rolePermission.belongsTo(db.roles, {
|
|
foreignKey: "role_id",
|
|
as: "role"
|
|
});
|
|
rolePermission.belongsTo(db.permission, {
|
|
foreignKey: "permission_id",
|
|
as: "permission"
|
|
});
|
|
};
|
|
|
|
return rolePermission;
|
|
};
|