@kipicore/dbcore 1.1.457 → 1.1.458

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ const sequelize_1 = require("sequelize");
4
4
  const index_1 = require("./index");
5
5
  class Permission extends sequelize_1.Model {
6
6
  static associate(models) {
7
- const { UserModel, InstituteModel, AcademicCalendarModel } = models;
7
+ const { UserModel, InstituteModel, AcademicCalendarModel, RoleManagementModel } = models;
8
8
  Permission.belongsTo(UserModel, {
9
9
  foreignKey: {
10
10
  name: 'createdBy',
@@ -57,6 +57,34 @@ class Permission extends sequelize_1.Model {
57
57
  },
58
58
  as: 'acaCalPermission',
59
59
  });
60
+ Permission.belongsTo(UserModel, {
61
+ foreignKey: {
62
+ name: 'userId',
63
+ field: 'user_id',
64
+ },
65
+ as: 'permissionUser',
66
+ });
67
+ UserModel.hasMany(Permission, {
68
+ foreignKey: {
69
+ name: 'userId',
70
+ field: 'user_id',
71
+ },
72
+ as: 'userPermission',
73
+ });
74
+ Permission.belongsTo(RoleManagementModel, {
75
+ foreignKey: {
76
+ name: 'roleId',
77
+ field: 'role_id',
78
+ },
79
+ as: 'userRole',
80
+ });
81
+ RoleManagementModel.hasMany(Permission, {
82
+ foreignKey: {
83
+ name: 'roleId',
84
+ field: 'role_id',
85
+ },
86
+ as: 'roleUser',
87
+ });
60
88
  }
61
89
  }
62
90
  Permission.init({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.457",
3
+ "version": "1.1.458",
4
4
  "description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",