@kipicore/dbcore 1.1.361 → 1.1.362

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.
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any, Sequelize: any): Promise<void>;
2
+ export function down(queryInterface: any): Promise<void>;
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ const up = async (queryInterface, Sequelize) => {
3
+ const tableName = 'subject_internal_marks';
4
+ const tableExists = await queryInterface
5
+ .describeTable(tableName)
6
+ .then(() => true)
7
+ .catch(() => false);
8
+ if (!tableExists) {
9
+ await queryInterface.createTable(tableName, {
10
+ id: {
11
+ type: Sequelize.UUID,
12
+ defaultValue: Sequelize.UUIDV4,
13
+ allowNull: false,
14
+ primaryKey: true,
15
+ },
16
+ academicCalendarId: {
17
+ type: Sequelize.UUID,
18
+ field: 'academic_calendar_id',
19
+ allowNull: true,
20
+ },
21
+ instituteId: {
22
+ type: Sequelize.UUID,
23
+ field: 'institute_id',
24
+ allowNull: true,
25
+ },
26
+ subjectId: {
27
+ type: Sequelize.UUID,
28
+ field: 'subject_id',
29
+ allowNull: true,
30
+ },
31
+ standardId: {
32
+ type: Sequelize.UUID,
33
+ field: 'standard_id',
34
+ allowNull: true,
35
+ },
36
+ totalMark: {
37
+ type: Sequelize.INTEGER,
38
+ field: 'total_mark',
39
+ allowNull: true,
40
+ defaultValue: 0,
41
+ },
42
+ createdBy: {
43
+ type: Sequelize.UUID,
44
+ allowNull: true,
45
+ field: 'created_by',
46
+ },
47
+ updatedBy: {
48
+ type: Sequelize.UUID,
49
+ allowNull: true,
50
+ field: 'updated_by',
51
+ },
52
+ deletedBy: {
53
+ type: Sequelize.UUID,
54
+ allowNull: true,
55
+ field: 'deleted_by',
56
+ },
57
+ createdAt: {
58
+ type: Sequelize.DATE,
59
+ allowNull: false,
60
+ field: 'created_at',
61
+ },
62
+ updatedAt: {
63
+ type: Sequelize.DATE,
64
+ allowNull: false,
65
+ field: 'updated_at',
66
+ },
67
+ deletedAt: {
68
+ type: Sequelize.DATE,
69
+ allowNull: true,
70
+ field: 'deleted_at',
71
+ },
72
+ });
73
+ }
74
+ else {
75
+ const tableDefinition = await queryInterface.describeTable(tableName);
76
+ const columnsToAdd = {
77
+ id: {
78
+ type: Sequelize.UUID,
79
+ defaultValue: Sequelize.UUIDV4,
80
+ allowNull: false,
81
+ primaryKey: true,
82
+ },
83
+ academicCalendarId: {
84
+ type: Sequelize.UUID,
85
+ field: 'academic_calendar_id',
86
+ allowNull: true,
87
+ },
88
+ instituteId: {
89
+ type: Sequelize.UUID,
90
+ field: 'institute_id',
91
+ allowNull: true,
92
+ },
93
+ subjectId: {
94
+ type: Sequelize.UUID,
95
+ field: 'subject_id',
96
+ allowNull: true,
97
+ },
98
+ standardId: {
99
+ type: Sequelize.UUID,
100
+ field: 'standard_id',
101
+ allowNull: true,
102
+ },
103
+ totalMark: {
104
+ type: Sequelize.INTEGER,
105
+ field: 'total_mark',
106
+ allowNull: true,
107
+ defaultValue: 0,
108
+ },
109
+ createdBy: {
110
+ type: Sequelize.UUID,
111
+ allowNull: true,
112
+ field: 'created_by',
113
+ },
114
+ updatedBy: {
115
+ type: Sequelize.UUID,
116
+ allowNull: true,
117
+ field: 'updated_by',
118
+ },
119
+ deletedBy: {
120
+ type: Sequelize.UUID,
121
+ allowNull: true,
122
+ field: 'deleted_by',
123
+ },
124
+ createdAt: {
125
+ type: Sequelize.DATE,
126
+ allowNull: false,
127
+ field: 'created_at',
128
+ },
129
+ updatedAt: {
130
+ type: Sequelize.DATE,
131
+ allowNull: false,
132
+ field: 'updated_at',
133
+ },
134
+ deletedAt: {
135
+ type: Sequelize.DATE,
136
+ allowNull: true,
137
+ field: 'deleted_at',
138
+ },
139
+ };
140
+ for (const column of Object.keys(columnsToAdd)) {
141
+ const columnToAdd = columnsToAdd[column];
142
+ const tableColumn = columnToAdd.field || column;
143
+ if (!tableDefinition[tableColumn]) {
144
+ await queryInterface.addColumn(tableName, tableColumn, columnToAdd);
145
+ }
146
+ }
147
+ }
148
+ };
149
+ const down = async (queryInterface) => {
150
+ const tableName = 'subject_internal_marks';
151
+ const tableExists = await queryInterface
152
+ .describeTable(tableName)
153
+ .then(() => true)
154
+ .catch(() => false);
155
+ if (tableExists) {
156
+ await queryInterface.dropTable(tableName);
157
+ }
158
+ };
159
+ module.exports = {
160
+ up,
161
+ down,
162
+ };
@@ -0,0 +1,9 @@
1
+ import { IDefaultAttributes } from './commonInterface';
2
+ export interface ISubjectInternalMarkModelAttributes extends IDefaultAttributes {
3
+ id: string;
4
+ instituteId: string;
5
+ academicCalendarId: string;
6
+ subjectId: string;
7
+ totalMark: number;
8
+ standardId: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ import { Model } from 'sequelize';
2
+ import { ISubjectInternalMarkModelAttributes } from '../../interfaces/subjectInternalMarkInterface';
3
+ import { TSubjectInternalMarkModelCreationAttributes } from '../../types/subjectInternalMarkType';
4
+ declare class SubjectInternalMarkModel extends Model<ISubjectInternalMarkModelAttributes, TSubjectInternalMarkModelCreationAttributes> {
5
+ id: string;
6
+ instituteId?: string;
7
+ academicCalendarId: string;
8
+ subjectId: string;
9
+ totalMark: number;
10
+ standardId: string;
11
+ createdBy: string;
12
+ updatedBy: string;
13
+ deletedBy: string;
14
+ readonly createdAt: Date;
15
+ readonly updatedAt: Date;
16
+ readonly deletedAt?: Date;
17
+ static associate(models: any): void;
18
+ }
19
+ export default SubjectInternalMarkModel;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const sequelize_1 = require("sequelize");
4
+ const index_1 = require("./index");
5
+ class SubjectInternalMarkModel extends sequelize_1.Model {
6
+ static associate(models) {
7
+ const { UserModel, InstituteModel, InstituteEntityModel } = models;
8
+ SubjectInternalMarkModel.belongsTo(UserModel, {
9
+ foreignKey: {
10
+ name: 'createdBy',
11
+ allowNull: true,
12
+ field: 'created_by',
13
+ },
14
+ as: 'createdByUser',
15
+ });
16
+ SubjectInternalMarkModel.belongsTo(UserModel, {
17
+ foreignKey: {
18
+ name: 'updatedBy',
19
+ allowNull: true,
20
+ field: 'updated_by',
21
+ },
22
+ as: 'updatedByUser',
23
+ });
24
+ SubjectInternalMarkModel.belongsTo(UserModel, {
25
+ foreignKey: {
26
+ name: 'deletedBy',
27
+ allowNull: true,
28
+ field: 'deleted_by',
29
+ },
30
+ as: 'deletedByUser',
31
+ });
32
+ SubjectInternalMarkModel.belongsTo(InstituteModel, {
33
+ foreignKey: 'instituteId',
34
+ as: 'subjectSubjectInternalMarkInstitute',
35
+ });
36
+ InstituteModel.hasMany(SubjectInternalMarkModel, {
37
+ foreignKey: 'instituteId',
38
+ as: 'instituteHasSubjectInternalMark',
39
+ });
40
+ SubjectInternalMarkModel.belongsTo(InstituteEntityModel, {
41
+ foreignKey: 'subjectId',
42
+ as: 'subjectSubjectInternalMark',
43
+ });
44
+ InstituteEntityModel.hasMany(SubjectInternalMarkModel, {
45
+ foreignKey: 'subjectId',
46
+ as: 'subjectHasInternalMark',
47
+ });
48
+ SubjectInternalMarkModel.belongsTo(InstituteEntityModel, {
49
+ foreignKey: 'standardId',
50
+ as: 'standardSubjectInternalMark',
51
+ });
52
+ InstituteEntityModel.hasMany(SubjectInternalMarkModel, {
53
+ foreignKey: 'standardId',
54
+ as: 'standardHasInternalMark',
55
+ });
56
+ }
57
+ }
58
+ SubjectInternalMarkModel.init({
59
+ id: {
60
+ type: sequelize_1.DataTypes.UUID,
61
+ defaultValue: sequelize_1.DataTypes.UUIDV4,
62
+ allowNull: false,
63
+ primaryKey: true,
64
+ },
65
+ academicCalendarId: {
66
+ type: sequelize_1.DataTypes.UUID,
67
+ field: 'academic_calendar_id',
68
+ allowNull: true,
69
+ },
70
+ instituteId: {
71
+ type: sequelize_1.DataTypes.UUID,
72
+ field: 'institute_id',
73
+ allowNull: true,
74
+ },
75
+ subjectId: {
76
+ type: sequelize_1.DataTypes.UUID,
77
+ field: 'subject_id',
78
+ allowNull: true,
79
+ },
80
+ totalMark: {
81
+ type: sequelize_1.DataTypes.INTEGER,
82
+ field: 'total_mark',
83
+ allowNull: true,
84
+ defaultValue: 0,
85
+ },
86
+ standardId: {
87
+ type: sequelize_1.DataTypes.UUID,
88
+ field: 'standard_id',
89
+ allowNull: true,
90
+ },
91
+ }, {
92
+ modelName: 'SubjectInternalMarkModel',
93
+ tableName: 'subject_internal_marks',
94
+ timestamps: true,
95
+ sequelize: index_1.sequelize,
96
+ });
97
+ exports.default = SubjectInternalMarkModel;
@@ -0,0 +1,9 @@
1
+ import { IBatchModelAttributes, IInstituteAttributes, IInstituteEntityAttributes, IUserAttributes } from '../interfaces';
2
+ import { ISubjectInternalMarkModelAttributes } from '../interfaces/subjectInternalMarkInterface';
3
+ export type TSubjectInternalMarkModelCreationAttributes = Partial<ISubjectInternalMarkModelAttributes>;
4
+ export type TSubjectInternalMarkWithAssociation = ISubjectInternalMarkModelAttributes & {
5
+ subjectSubjectInternalMarkBatch?: IBatchModelAttributes;
6
+ subjectSubjectInternalMarkSubject?: IInstituteEntityAttributes;
7
+ subjectSubjectInternalMarkUser?: IUserAttributes;
8
+ subjectSubjectInternalMarkInstitute?: IInstituteAttributes;
9
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.361",
3
+ "version": "1.1.362",
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",