@kipicore/dbcore 1.1.5 → 1.1.6
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.
- package/README.md +1 -1
- package/dist/constants/app.js +0 -1
- package/dist/db/mongodb.js +4 -4
- package/dist/db/postgres.d.ts +1 -1
- package/dist/db/postgres.js +5 -5
- package/dist/index.d.ts +417 -415
- package/dist/index.js +742 -428
- package/dist/models/mongodb/attendanceModel.d.ts +2 -2
- package/dist/models/mongodb/attendanceModel.js +7 -8
- package/dist/models/mongodb/eventModel.d.ts +2 -2
- package/dist/models/mongodb/eventModel.js +3 -3
- package/dist/models/mongodb/examGroupModel.d.ts +2 -2
- package/dist/models/mongodb/examGroupModel.js +22 -28
- package/dist/models/mongodb/examHasAnswerSheetModel.d.ts +2 -2
- package/dist/models/mongodb/examHasAnswerSheetModel.js +5 -6
- package/dist/models/mongodb/examModel.d.ts +2 -2
- package/dist/models/mongodb/examModel.js +7 -10
- package/dist/models/mongodb/holidayModel.d.ts +2 -2
- package/dist/models/mongodb/holidayModel.js +4 -6
- package/dist/models/mongodb/inquiryModel.d.ts +2 -2
- package/dist/models/mongodb/inquiryModel.js +3 -4
- package/dist/models/mongodb/plugin/transformIdInResponsePlugin.d.ts +1 -1
- package/dist/models/mongodb/plugin/transformIdInResponsePlugin.js +4 -6
- package/dist/models/mongodb/schoolFeeModel.d.ts +2 -2
- package/dist/models/mongodb/schoolFeeModel.js +3 -3
- package/dist/models/mongodb/subjectIndexModel.d.ts +2 -2
- package/dist/models/mongodb/subjectIndexModel.js +66 -108
- package/dist/models/mongodb/subscriptionPlanModel.d.ts +2 -2
- package/dist/models/mongodb/subscriptionPlanModel.js +1 -1
- package/dist/models/mongodb/taskManagementModel.d.ts +2 -2
- package/dist/models/mongodb/taskManagementModel.js +3 -3
- package/dist/models/mongodb/userDoc.d.ts +1 -1
- package/dist/models/mongodb/userDoc.js +1 -1
- package/dist/models/mongodb/userSchoolMetaModel.d.ts +1 -1
- package/dist/models/mongodb/userSchoolMetaModel.js +8 -8
- package/dist/models/psql/announcementModel.d.ts +4 -4
- package/dist/models/psql/announcementModel.js +25 -25
- package/dist/models/psql/batchModel.d.ts +4 -4
- package/dist/models/psql/batchModel.js +51 -51
- package/dist/models/psql/driverModel.d.ts +4 -4
- package/dist/models/psql/driverModel.js +28 -28
- package/dist/models/psql/facilityModel.d.ts +4 -4
- package/dist/models/psql/facilityModel.js +23 -23
- package/dist/models/psql/feeHistoryModel.d.ts +4 -4
- package/dist/models/psql/feeHistoryModel.js +64 -65
- package/dist/models/psql/feeReminderModel.d.ts +3 -3
- package/dist/models/psql/feeReminderModel.js +32 -32
- package/dist/models/psql/feesCollectionModel.d.ts +4 -4
- package/dist/models/psql/feesCollectionModel.js +36 -37
- package/dist/models/psql/index.d.ts +1 -1
- package/dist/models/psql/index.js +12 -12
- package/dist/models/psql/lectureModel.d.ts +4 -4
- package/dist/models/psql/lectureModel.js +75 -84
- package/dist/models/psql/masterLeaveModel.d.ts +4 -4
- package/dist/models/psql/masterLeaveModel.js +22 -23
- package/dist/models/psql/testimonialModel.d.ts +4 -4
- package/dist/models/psql/testimonialModel.js +25 -27
- package/dist/models/psql/toDoModel.d.ts +4 -4
- package/dist/models/psql/toDoModel.js +23 -23
- package/dist/models/psql/typeManagementModel.d.ts +4 -4
- package/dist/models/psql/typeManagementModel.js +19 -19
- package/dist/models/psql/userModel.d.ts +4 -4
- package/dist/models/psql/userModel.js +47 -48
- package/dist/models/psql/userPayoutModel.d.ts +4 -4
- package/dist/models/psql/userPayoutModel.js +55 -70
- package/dist/services/Concrete/mongooseCommonService.d.ts +4 -4
- package/dist/services/Concrete/mongooseCommonService.js +2 -4
- package/dist/services/Contracts/IMongooseCommonService.d.ts +2 -2
- package/dist/services/Contracts/ISequelizeCommonService.d.ts +12 -12
- package/dist/types/generateIdCardType.d.ts +2 -2
- package/package.json +49 -47
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { IAttendanceModelAttributes } from
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { IAttendanceModelAttributes } from '../../interfaces/attendanceInterface.js';
|
|
3
3
|
declare const AttendanceModel: Model<IAttendanceModelAttributes>;
|
|
4
4
|
export default AttendanceModel;
|
|
@@ -104,7 +104,7 @@ const attendanceModelSchema = new mongoose_1.Schema({
|
|
|
104
104
|
versionKey: false,
|
|
105
105
|
virtuals: true,
|
|
106
106
|
});
|
|
107
|
-
attendanceModelSchema.pre(
|
|
107
|
+
attendanceModelSchema.pre('save', async function (next) {
|
|
108
108
|
const attendance = this;
|
|
109
109
|
try {
|
|
110
110
|
if (attendance.instituteId) {
|
|
@@ -126,12 +126,12 @@ attendanceModelSchema.pre("save", async function (next) {
|
|
|
126
126
|
const userHasBatchList = await userHasBatchModel_js_1.default.findAll({
|
|
127
127
|
where: {
|
|
128
128
|
userId: {
|
|
129
|
-
[sequelize_1.Op.in]: attendance.users.map(
|
|
129
|
+
[sequelize_1.Op.in]: attendance.users.map(user => user.userId),
|
|
130
130
|
},
|
|
131
131
|
},
|
|
132
132
|
include: [
|
|
133
|
-
{ association:
|
|
134
|
-
{ association:
|
|
133
|
+
{ association: 'batch', where: batchWhere },
|
|
134
|
+
{ association: 'user', where: { type: attendance.userType } },
|
|
135
135
|
],
|
|
136
136
|
});
|
|
137
137
|
for (const user of attendance.users) {
|
|
@@ -142,8 +142,7 @@ attendanceModelSchema.pre("save", async function (next) {
|
|
|
142
142
|
if (attendance.type === app_js_1.ATTENDANCE_TYPE.BATCH) {
|
|
143
143
|
if (!attendance.batchId)
|
|
144
144
|
throw new Error(errorMessages_js_1.ATTENDANCE_ERROR_MESSAGES.USER_BATCH_NOT_FOUND);
|
|
145
|
-
const userHasbatch = userHasBatchList.find(
|
|
146
|
-
userBatch.userId === user.userId);
|
|
145
|
+
const userHasbatch = userHasBatchList.find(userBatch => userBatch.batchId === attendance.batchId && userBatch.userId === user.userId);
|
|
147
146
|
if (!userHasbatch || !userHasbatch.batch)
|
|
148
147
|
throw new Error(errorMessages_js_1.ATTENDANCE_ERROR_MESSAGES.USER_HAS_BATCH_NOT_FOUND);
|
|
149
148
|
startTime = userHasbatch.batch.startTime;
|
|
@@ -172,7 +171,7 @@ attendanceModelSchema.index({
|
|
|
172
171
|
batchId: 1,
|
|
173
172
|
userType: 1,
|
|
174
173
|
instituteId: 1,
|
|
175
|
-
|
|
174
|
+
'users.userId': 1,
|
|
176
175
|
});
|
|
177
|
-
const AttendanceModel = mongoose_1.default.model(
|
|
176
|
+
const AttendanceModel = mongoose_1.default.model('attendance', attendanceModelSchema);
|
|
178
177
|
exports.default = AttendanceModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { IEventModelAttributes } from
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { IEventModelAttributes } from '../../interfaces/eventInterface.js';
|
|
3
3
|
declare const EventModel: Model<IEventModelAttributes>;
|
|
4
4
|
export default EventModel;
|
|
@@ -120,7 +120,7 @@ const eventModelSchema = new mongoose_1.Schema({
|
|
|
120
120
|
timestamps: true,
|
|
121
121
|
versionKey: false,
|
|
122
122
|
});
|
|
123
|
-
eventModelSchema.pre(
|
|
123
|
+
eventModelSchema.pre('save', async function (next) {
|
|
124
124
|
const event = this;
|
|
125
125
|
try {
|
|
126
126
|
// If type is BATCH, ensure instituteId and batches exist
|
|
@@ -155,9 +155,9 @@ eventModelSchema.pre("save", async function (next) {
|
|
|
155
155
|
return next(error);
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
-
eventModelSchema.index({ instituteId: 1, status: 1,
|
|
158
|
+
eventModelSchema.index({ instituteId: 1, status: 1, 'batches.batchId': 1 });
|
|
159
159
|
eventModelSchema.index({ instituteId: 1, status: 1, batches: 1 });
|
|
160
|
-
const EventModel = mongoose_1.default.model(
|
|
160
|
+
const EventModel = mongoose_1.default.model('event', eventModelSchema);
|
|
161
161
|
// (async () => {
|
|
162
162
|
// await EventModel.syncIndexes();
|
|
163
163
|
// })(); // Rebuilds indexes in DB based on schema
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { IExamGroupModelAttributes } from
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { IExamGroupModelAttributes } from '../../interfaces/examGroupInterface.js';
|
|
3
3
|
declare const ExamGroupModel: Model<IExamGroupModelAttributes>;
|
|
4
4
|
export default ExamGroupModel;
|
|
@@ -168,7 +168,7 @@ const createOrUpdateHook = async (examGroup) => {
|
|
|
168
168
|
examGroup.subjects = [];
|
|
169
169
|
}
|
|
170
170
|
if (examGroup.standardByDays) {
|
|
171
|
-
examGroup.standardByDays = examGroup.standardByDays.filter(
|
|
171
|
+
examGroup.standardByDays = examGroup.standardByDays.filter(standardByDays => examGroup.standards.includes(standardByDays.standardId));
|
|
172
172
|
const userInstituteMeta = await userInstituteMetaModel_js_1.default.findOne({
|
|
173
173
|
userId: examGroup.instituteId,
|
|
174
174
|
instituteId: examGroup.instituteId,
|
|
@@ -178,10 +178,10 @@ const createOrUpdateHook = async (examGroup) => {
|
|
|
178
178
|
entityId: { [sequelize_1.Op.in]: userInstituteMeta?.entities },
|
|
179
179
|
},
|
|
180
180
|
});
|
|
181
|
-
subjectList = subjectList.filter(
|
|
182
|
-
subjectList = subjectList.filter(
|
|
183
|
-
examGroup.subjects = subjectList.map(
|
|
184
|
-
const subjectListByStandardId = (0, utils_js_1.groupByFieldOrFields)(subjectList,
|
|
181
|
+
subjectList = subjectList.filter(subject => examGroup.standards.includes(subject.entityId));
|
|
182
|
+
subjectList = subjectList.filter(subject => userInstituteMeta?.entities?.includes(subject.id));
|
|
183
|
+
examGroup.subjects = subjectList.map(subject => subject.id);
|
|
184
|
+
const subjectListByStandardId = (0, utils_js_1.groupByFieldOrFields)(subjectList, 'entityId');
|
|
185
185
|
const dateList = [];
|
|
186
186
|
let startDate = examGroup.startDate;
|
|
187
187
|
while (new Date(startDate).getTime() < new Date(examGroup.endDate).getTime()) {
|
|
@@ -193,31 +193,27 @@ const createOrUpdateHook = async (examGroup) => {
|
|
|
193
193
|
continue;
|
|
194
194
|
// const standardSubjectList = subjectListByStandardId[standard].map((entity: { id: string }) => entity.id);
|
|
195
195
|
// const batches = await this.batchService.findAll({ subjects: { [Op.overlap]: standardSubjectList } });
|
|
196
|
-
const existStandardByDays = examGroup.standardByDays.find(
|
|
197
|
-
const existStandardByDaysIndex = examGroup.standardByDays.findIndex(
|
|
196
|
+
const existStandardByDays = examGroup.standardByDays.find(standardByDays => standardByDays.standardId === standard);
|
|
197
|
+
const existStandardByDaysIndex = examGroup.standardByDays.findIndex(standardByDays => standardByDays.standardId === standard);
|
|
198
198
|
let standardByDays = {
|
|
199
199
|
standardId: standard,
|
|
200
200
|
// batches: batches.map(batch => batch.id),
|
|
201
201
|
// subjects: standardSubjectList,
|
|
202
202
|
days: [],
|
|
203
203
|
};
|
|
204
|
-
dateList.forEach(
|
|
204
|
+
dateList.forEach(date => {
|
|
205
205
|
const dayObject = {
|
|
206
206
|
date,
|
|
207
|
-
note:
|
|
208
|
-
subjectId:
|
|
207
|
+
note: '',
|
|
208
|
+
subjectId: '',
|
|
209
209
|
isHoliday: false,
|
|
210
210
|
};
|
|
211
211
|
if (existStandardByDays) {
|
|
212
|
-
existStandardByDays.days = existStandardByDays.days.filter(
|
|
213
|
-
return dateList
|
|
214
|
-
.map((date) => new Date(date).getTime())
|
|
215
|
-
.includes(new Date(day.date).getTime());
|
|
212
|
+
existStandardByDays.days = existStandardByDays.days.filter(day => {
|
|
213
|
+
return dateList.map(date => new Date(date).getTime()).includes(new Date(day.date).getTime());
|
|
216
214
|
});
|
|
217
|
-
const existDate = existStandardByDays.days.find(
|
|
218
|
-
return dateList
|
|
219
|
-
.map((date) => new Date(date).getTime())
|
|
220
|
-
.includes(new Date(day.date).getTime());
|
|
215
|
+
const existDate = existStandardByDays.days.find(day => {
|
|
216
|
+
return dateList.map(date => new Date(date).getTime()).includes(new Date(day.date).getTime());
|
|
221
217
|
});
|
|
222
218
|
if (!existDate)
|
|
223
219
|
existStandardByDays.days.push(dayObject);
|
|
@@ -227,9 +223,8 @@ const createOrUpdateHook = async (examGroup) => {
|
|
|
227
223
|
}
|
|
228
224
|
});
|
|
229
225
|
if (existStandardByDays) {
|
|
230
|
-
examGroup.standardByDays[existStandardByDaysIndex] =
|
|
231
|
-
|
|
232
|
-
const isNotValidHoliday = examGroup.standardByDays[existStandardByDaysIndex].days.some((day) => day.isHoliday && day.subjectId.length > 1);
|
|
226
|
+
examGroup.standardByDays[existStandardByDaysIndex] = existStandardByDays;
|
|
227
|
+
const isNotValidHoliday = examGroup.standardByDays[existStandardByDaysIndex].days.some(day => day.isHoliday && day.subjectId.length > 1);
|
|
233
228
|
if (isNotValidHoliday)
|
|
234
229
|
throw new Error(errorMessages_js_1.EXAM_GROUP_ERROR_MESSAGES.INVALID_HOLIDAY);
|
|
235
230
|
standardByDays = { ...existStandardByDays };
|
|
@@ -244,14 +239,13 @@ const createOrUpdateHook = async (examGroup) => {
|
|
|
244
239
|
// }
|
|
245
240
|
}
|
|
246
241
|
//*********** days array remove duplicate date from date if multiple date empty ********///
|
|
247
|
-
examGroup.standardByDays = examGroup.standardByDays.map(
|
|
242
|
+
examGroup.standardByDays = examGroup.standardByDays.map(standard => ({
|
|
248
243
|
...standard,
|
|
249
244
|
days: standard.days.reduce((acc, day) => {
|
|
250
|
-
const existingIndex = acc.findIndex(
|
|
245
|
+
const existingIndex = acc.findIndex(d => new Date(d.date).getTime() === new Date(day.date).getTime());
|
|
251
246
|
if (Object.keys(day.examDetails || {}).length > 0) {
|
|
252
247
|
// If an empty object exists for this date, remove it
|
|
253
|
-
if (existingIndex !== -1 &&
|
|
254
|
-
Object.keys(acc[existingIndex].examDetails || {}).length === 0) {
|
|
248
|
+
if (existingIndex !== -1 && Object.keys(acc[existingIndex].examDetails || {}).length === 0) {
|
|
255
249
|
acc.splice(existingIndex, 1);
|
|
256
250
|
}
|
|
257
251
|
acc.push(day);
|
|
@@ -269,7 +263,7 @@ const createOrUpdateHook = async (examGroup) => {
|
|
|
269
263
|
throw err;
|
|
270
264
|
}
|
|
271
265
|
};
|
|
272
|
-
examGroupModelSchema.pre(
|
|
266
|
+
examGroupModelSchema.pre('save', async function (next) {
|
|
273
267
|
const subjectIndex = this;
|
|
274
268
|
try {
|
|
275
269
|
await createOrUpdateHook(subjectIndex);
|
|
@@ -279,7 +273,7 @@ examGroupModelSchema.pre("save", async function (next) {
|
|
|
279
273
|
throw error;
|
|
280
274
|
}
|
|
281
275
|
});
|
|
282
|
-
examGroupModelSchema.pre(
|
|
276
|
+
examGroupModelSchema.pre('updateMany', async function (next) {
|
|
283
277
|
const subjectIndex = this.getUpdate();
|
|
284
278
|
try {
|
|
285
279
|
await createOrUpdateHook(subjectIndex);
|
|
@@ -289,5 +283,5 @@ examGroupModelSchema.pre("updateMany", async function (next) {
|
|
|
289
283
|
throw error;
|
|
290
284
|
}
|
|
291
285
|
});
|
|
292
|
-
const ExamGroupModel = mongoose_1.default.model(
|
|
286
|
+
const ExamGroupModel = mongoose_1.default.model('exam_groups', examGroupModelSchema);
|
|
293
287
|
exports.default = ExamGroupModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { IExamHasAnswerSheetModelAttributes } from
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { IExamHasAnswerSheetModelAttributes } from '../../interfaces/examHasAnswerSheetInterface.js';
|
|
3
3
|
declare const ExamHasAnswerSheetModel: Model<IExamHasAnswerSheetModelAttributes>;
|
|
4
4
|
export default ExamHasAnswerSheetModel;
|
|
@@ -64,13 +64,12 @@ const AnswerSheetQuestionSchema = new mongoose_1.Schema({
|
|
|
64
64
|
default: app_js_1.EXAM_ANSWER_SHEET_QUESTION_RESULT.NOT_ATTENDED,
|
|
65
65
|
required: false,
|
|
66
66
|
},
|
|
67
|
-
}, { _id: false }
|
|
68
|
-
);
|
|
67
|
+
}, { _id: false });
|
|
69
68
|
// Define the main schema for IExamHasAnswerSheetModelAttributes
|
|
70
69
|
const examHasAnswerSheetSchema = new mongoose_1.Schema({
|
|
71
70
|
examId: {
|
|
72
71
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
73
|
-
ref:
|
|
72
|
+
ref: 'exams',
|
|
74
73
|
required: true,
|
|
75
74
|
},
|
|
76
75
|
questions: {
|
|
@@ -114,7 +113,7 @@ const examHasAnswerSheetSchema = new mongoose_1.Schema({
|
|
|
114
113
|
},
|
|
115
114
|
studentExamIp: {
|
|
116
115
|
type: String,
|
|
117
|
-
default:
|
|
116
|
+
default: '',
|
|
118
117
|
required: false,
|
|
119
118
|
},
|
|
120
119
|
}, {
|
|
@@ -122,12 +121,12 @@ const examHasAnswerSheetSchema = new mongoose_1.Schema({
|
|
|
122
121
|
versionKey: false,
|
|
123
122
|
});
|
|
124
123
|
// Add a pre-save hook to validate examId existence
|
|
125
|
-
examHasAnswerSheetSchema.pre(
|
|
124
|
+
examHasAnswerSheetSchema.pre('save', async function (next) {
|
|
126
125
|
const examExists = await examModel_js_1.default.findOne({ where: { id: this.examId } });
|
|
127
126
|
if (!examExists) {
|
|
128
127
|
return next(new Error(errorMessages_js_1.EXAM_ERROR_MESSAGES.NOT_FOUND));
|
|
129
128
|
}
|
|
130
129
|
next();
|
|
131
130
|
});
|
|
132
|
-
const ExamHasAnswerSheetModel = mongoose_1.default.model(
|
|
131
|
+
const ExamHasAnswerSheetModel = mongoose_1.default.model('exam_answer_sheets', examHasAnswerSheetSchema);
|
|
133
132
|
exports.default = ExamHasAnswerSheetModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { IExamModelAttributes } from
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { IExamModelAttributes } from '../../interfaces/examInterface.js';
|
|
3
3
|
declare const ExamModel: Model<IExamModelAttributes>;
|
|
4
4
|
export default ExamModel;
|
|
@@ -67,8 +67,7 @@ const ExamHasBatchSchema = new mongoose_1.Schema({
|
|
|
67
67
|
type: Boolean,
|
|
68
68
|
default: false,
|
|
69
69
|
},
|
|
70
|
-
}, { _id: false }
|
|
71
|
-
);
|
|
70
|
+
}, { _id: false });
|
|
72
71
|
const examModelSchema = new mongoose_1.Schema({
|
|
73
72
|
title: {
|
|
74
73
|
type: String,
|
|
@@ -191,7 +190,7 @@ const examModelSchema = new mongoose_1.Schema({
|
|
|
191
190
|
timestamps: true,
|
|
192
191
|
versionKey: false,
|
|
193
192
|
});
|
|
194
|
-
examModelSchema.pre(
|
|
193
|
+
examModelSchema.pre('save', async function (next) {
|
|
195
194
|
const exam = this;
|
|
196
195
|
try {
|
|
197
196
|
if (exam.batches && exam.batches.length && exam.subject) {
|
|
@@ -203,7 +202,7 @@ examModelSchema.pre("save", async function (next) {
|
|
|
203
202
|
return next(new Error(errorMessages_js_1.BATCH_ERROR_MESSAGES.INVALID_SELECTED));
|
|
204
203
|
}
|
|
205
204
|
where = {
|
|
206
|
-
id: { [sequelize_1.Op.in]: exam.batches.map(
|
|
205
|
+
id: { [sequelize_1.Op.in]: exam.batches.map(batch => batch.batchId) },
|
|
207
206
|
subjects: { [sequelize_1.Op.overlap]: [exam.subject] },
|
|
208
207
|
};
|
|
209
208
|
const batchesList = await batchModel_js_1.default.findAll({ where });
|
|
@@ -212,12 +211,10 @@ examModelSchema.pre("save", async function (next) {
|
|
|
212
211
|
}
|
|
213
212
|
if (exam.mode === app_js_1.EXAM_MODE.OFFLINE && !exam.groupId) {
|
|
214
213
|
where = {
|
|
215
|
-
id: { [sequelize_1.Op.in]: exam.batches.map(
|
|
214
|
+
id: { [sequelize_1.Op.in]: exam.batches.map(batch => batch.classroomId) },
|
|
216
215
|
};
|
|
217
216
|
const classroomCount = await classRoomModel_js_1.default.count({ where });
|
|
218
|
-
const classroomDataount = [
|
|
219
|
-
...new Set(exam.batches.map((val) => val.classroomId)),
|
|
220
|
-
].length;
|
|
217
|
+
const classroomDataount = [...new Set(exam.batches.map(val => val.classroomId))].length;
|
|
221
218
|
if (classroomCount !== classroomDataount) {
|
|
222
219
|
return next(new Error(errorMessages_js_1.CLASSROOM_ERROR_MESSAGES.INVALID_SELECTED));
|
|
223
220
|
}
|
|
@@ -254,13 +251,13 @@ examModelSchema.pre("save", async function (next) {
|
|
|
254
251
|
});
|
|
255
252
|
examModelSchema.index({
|
|
256
253
|
instituteId: 1,
|
|
257
|
-
|
|
254
|
+
'batches.batchId': 1,
|
|
258
255
|
scheduleDate: 1,
|
|
259
256
|
subject: 1,
|
|
260
257
|
status: 1,
|
|
261
258
|
mode: 1,
|
|
262
259
|
});
|
|
263
|
-
const ExamModel = mongoose_1.default.model(
|
|
260
|
+
const ExamModel = mongoose_1.default.model('exams', examModelSchema);
|
|
264
261
|
// (async () => {
|
|
265
262
|
// await ExamModel.syncIndexes();
|
|
266
263
|
// })(); // Rebuilds indexes in DB based on schema
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { IHolidayModelAttributes } from
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { IHolidayModelAttributes } from '../../interfaces/holidayInterface.js';
|
|
3
3
|
declare const HolidayModel: Model<IHolidayModelAttributes>;
|
|
4
4
|
export default HolidayModel;
|
|
@@ -124,14 +124,12 @@ const holidayModelSchema = new mongoose_1.Schema({
|
|
|
124
124
|
timestamps: true,
|
|
125
125
|
versionKey: false,
|
|
126
126
|
});
|
|
127
|
-
holidayModelSchema.pre(
|
|
127
|
+
holidayModelSchema.pre('save', async function (next) {
|
|
128
128
|
const holiday = this;
|
|
129
129
|
try {
|
|
130
130
|
// If type is BATCH, ensure instituteId and batches exist
|
|
131
131
|
if (holiday.type === app_js_1.ACADEMIC_CALENDARS_TYPE.BATCH) {
|
|
132
|
-
if (!holiday.instituteId ||
|
|
133
|
-
!holiday.batches ||
|
|
134
|
-
holiday.batches.length === 0) {
|
|
132
|
+
if (!holiday.instituteId || !holiday.batches || holiday.batches.length === 0) {
|
|
135
133
|
return next(new Error(errorMessages_js_1.BATCH_ERROR_MESSAGES.INSTITUTED_BATCHES_REQUIRED));
|
|
136
134
|
}
|
|
137
135
|
}
|
|
@@ -163,9 +161,9 @@ holidayModelSchema.pre("save", async function (next) {
|
|
|
163
161
|
return next(error);
|
|
164
162
|
}
|
|
165
163
|
});
|
|
166
|
-
holidayModelSchema.index({ instituteId: 1, status: 1,
|
|
164
|
+
holidayModelSchema.index({ instituteId: 1, status: 1, 'batches.batchId': 1 });
|
|
167
165
|
holidayModelSchema.index({ instituteId: 1, status: 1, batches: 1 });
|
|
168
|
-
const HolidayModel = mongoose_1.default.model(
|
|
166
|
+
const HolidayModel = mongoose_1.default.model('holiday', holidayModelSchema);
|
|
169
167
|
// (async () => {
|
|
170
168
|
// await HolidayModel.syncIndexes();
|
|
171
169
|
// })(); // Rebuilds indexes in DB based on schema
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { IInquiryModelAttributes } from
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { IInquiryModelAttributes } from '../../interfaces/inquiryInterface.js';
|
|
3
3
|
declare const InquiryModel: Model<IInquiryModelAttributes>;
|
|
4
4
|
export default InquiryModel;
|
|
@@ -112,8 +112,7 @@ const AddressSchema = new mongoose_1.Schema({
|
|
|
112
112
|
type: Number,
|
|
113
113
|
required: false,
|
|
114
114
|
},
|
|
115
|
-
}, { _id: false }
|
|
116
|
-
);
|
|
115
|
+
}, { _id: false });
|
|
117
116
|
const InquirySchema = new mongoose_1.Schema({
|
|
118
117
|
instituteId: { type: String, required: false },
|
|
119
118
|
basicInformation: { type: BasicInformationSchema, required: true },
|
|
@@ -154,7 +153,7 @@ const InquirySchema = new mongoose_1.Schema({
|
|
|
154
153
|
timestamps: true,
|
|
155
154
|
versionKey: false,
|
|
156
155
|
});
|
|
157
|
-
InquirySchema.pre(
|
|
156
|
+
InquirySchema.pre('save', async function (next) {
|
|
158
157
|
const inquiry = this;
|
|
159
158
|
try {
|
|
160
159
|
if (inquiry.academicInformation.batchType) {
|
|
@@ -182,5 +181,5 @@ InquirySchema.pre("save", async function (next) {
|
|
|
182
181
|
return next(error);
|
|
183
182
|
}
|
|
184
183
|
});
|
|
185
|
-
const InquiryModel = mongoose_1.default.model(
|
|
184
|
+
const InquiryModel = mongoose_1.default.model('inquiry', InquirySchema);
|
|
186
185
|
exports.default = InquiryModel;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
8
|
const transformNestedDocs = (doc) => {
|
|
9
|
-
if (!doc || typeof doc !==
|
|
9
|
+
if (!doc || typeof doc !== 'object') {
|
|
10
10
|
return doc; // Skip non-object or null values
|
|
11
11
|
}
|
|
12
12
|
if (Array.isArray(doc)) {
|
|
@@ -19,9 +19,7 @@ const transformNestedDocs = (doc) => {
|
|
|
19
19
|
}
|
|
20
20
|
// Recursively process nested objects
|
|
21
21
|
for (const key of Object.keys(doc)) {
|
|
22
|
-
if (!mongoose_1.default.Types.ObjectId.isValid(doc[key]) &&
|
|
23
|
-
doc[key] &&
|
|
24
|
-
typeof doc[key] === "object") {
|
|
22
|
+
if (!mongoose_1.default.Types.ObjectId.isValid(doc[key]) && doc[key] && typeof doc[key] === 'object') {
|
|
25
23
|
doc[key] = transformNestedDocs(doc[key]);
|
|
26
24
|
}
|
|
27
25
|
}
|
|
@@ -29,7 +27,7 @@ const transformNestedDocs = (doc) => {
|
|
|
29
27
|
};
|
|
30
28
|
const transformIdInResponsePlugin = (schema) => {
|
|
31
29
|
// Apply `toJSON` and `toObject` transformations
|
|
32
|
-
schema.set(
|
|
30
|
+
schema.set('toJSON', {
|
|
33
31
|
virtuals: true,
|
|
34
32
|
transform: (_, ret) => {
|
|
35
33
|
if (ret._id !== undefined) {
|
|
@@ -39,7 +37,7 @@ const transformIdInResponsePlugin = (schema) => {
|
|
|
39
37
|
}
|
|
40
38
|
},
|
|
41
39
|
});
|
|
42
|
-
schema.set(
|
|
40
|
+
schema.set('toObject', {
|
|
43
41
|
virtuals: true,
|
|
44
42
|
transform: (_, ret) => {
|
|
45
43
|
if (ret._id !== undefined) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { ISchoolFeeModelAttributes } from
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { ISchoolFeeModelAttributes } from '../../interfaces/schoolFeeInterface.js';
|
|
3
3
|
declare const SchoolFeeModel: Model<ISchoolFeeModelAttributes>;
|
|
4
4
|
export default SchoolFeeModel;
|
|
@@ -118,11 +118,11 @@ const schoolFeeSchema = new mongoose_1.Schema({
|
|
|
118
118
|
timestamps: true,
|
|
119
119
|
versionKey: false,
|
|
120
120
|
});
|
|
121
|
-
schoolFeeSchema.pre(
|
|
121
|
+
schoolFeeSchema.pre('save', async function (next) {
|
|
122
122
|
const schoolFee = this;
|
|
123
123
|
try {
|
|
124
124
|
if (!schoolFee.fees || schoolFee.fees.length === 0) {
|
|
125
|
-
return next(new Error(
|
|
125
|
+
return next(new Error('Fees array cannot be empty.'));
|
|
126
126
|
}
|
|
127
127
|
if (schoolFee.instituteId) {
|
|
128
128
|
const institute = await instituteModel_js_1.default.findByPk(schoolFee.instituteId);
|
|
@@ -174,5 +174,5 @@ schoolFeeSchema.pre("save", async function (next) {
|
|
|
174
174
|
return next(error);
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
-
const SchoolFeeModel = mongoose_1.default.model(
|
|
177
|
+
const SchoolFeeModel = mongoose_1.default.model('schoolFee', schoolFeeSchema);
|
|
178
178
|
exports.default = SchoolFeeModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { ISubjectIndexModelAttributes } from
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { ISubjectIndexModelAttributes } from '../../interfaces/subjectIndexInterface.js';
|
|
3
3
|
declare const SubjectIndexModel: Model<ISubjectIndexModelAttributes>;
|
|
4
4
|
export default SubjectIndexModel;
|