Bansari Akhani
get user with associations - role & it's permissions
2f7395b
raw
history blame contribute delete
978 Bytes
import {
DataTypes,
Model,
InferAttributes,
InferCreationAttributes,
CreationOptional,
} from 'sequelize';
import { sequelize } from './index';
import { PermissionInterface } from '../shared/interfaces/permission.interface';
import Role from './roles';
import RolePermission from './rolePermissions';
class Permission extends Model<InferAttributes<Permission>, InferCreationAttributes<Permission>> implements PermissionInterface {
declare id: CreationOptional<number>;
declare permission_name: string;
}
Permission.init(
{
id: {
type: DataTypes.INTEGER.UNSIGNED,
autoIncrement: true,
primaryKey: true,
unique: true,
},
permission_name: {
type: DataTypes.STRING,
allowNull: false,
},
},
{
sequelize,
tableName: 'permissions',
underscored: true,
freezeTableName: true,
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
}
);
export default Permission;