@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
|
@@ -26,30 +26,30 @@ UserPayoutModel.init({
|
|
|
26
26
|
userId: {
|
|
27
27
|
type: sequelize_1.DataTypes.UUID,
|
|
28
28
|
allowNull: false,
|
|
29
|
-
field:
|
|
29
|
+
field: 'user_id',
|
|
30
30
|
},
|
|
31
31
|
userType: {
|
|
32
32
|
type: sequelize_1.DataTypes.ENUM,
|
|
33
33
|
values: Object.values(app_js_1.USER_TYPES),
|
|
34
34
|
allowNull: false,
|
|
35
|
-
field:
|
|
35
|
+
field: 'user_type',
|
|
36
36
|
},
|
|
37
37
|
instituteId: {
|
|
38
38
|
type: sequelize_1.DataTypes.UUID,
|
|
39
39
|
allowNull: false,
|
|
40
|
-
field:
|
|
40
|
+
field: 'institute_id',
|
|
41
41
|
},
|
|
42
42
|
totalPayableAmount: {
|
|
43
43
|
type: sequelize_1.DataTypes.FLOAT,
|
|
44
44
|
allowNull: true,
|
|
45
45
|
defaultValue: 0,
|
|
46
|
-
field:
|
|
46
|
+
field: 'total_payable_amount',
|
|
47
47
|
},
|
|
48
48
|
totalPaidAmount: {
|
|
49
49
|
type: sequelize_1.DataTypes.FLOAT,
|
|
50
50
|
allowNull: true,
|
|
51
51
|
defaultValue: 0,
|
|
52
|
-
field:
|
|
52
|
+
field: 'total_paid_amount',
|
|
53
53
|
},
|
|
54
54
|
type: {
|
|
55
55
|
type: sequelize_1.DataTypes.ENUM,
|
|
@@ -59,68 +59,67 @@ UserPayoutModel.init({
|
|
|
59
59
|
lastCalculatedAt: {
|
|
60
60
|
type: sequelize_1.DataTypes.DATE,
|
|
61
61
|
defaultValue: (0, date_fns_1.startOfToday)(),
|
|
62
|
-
field:
|
|
62
|
+
field: 'last_calculated_at',
|
|
63
63
|
},
|
|
64
64
|
}, {
|
|
65
|
-
modelName:
|
|
66
|
-
tableName:
|
|
65
|
+
modelName: 'UserPayoutModel',
|
|
66
|
+
tableName: 'user_payouts',
|
|
67
67
|
timestamps: true,
|
|
68
68
|
sequelize: index_js_1.sequelize,
|
|
69
69
|
});
|
|
70
70
|
UserPayoutModel.belongsTo(userModel_js_1.default, {
|
|
71
71
|
foreignKey: {
|
|
72
|
-
name:
|
|
72
|
+
name: 'createdBy',
|
|
73
73
|
allowNull: true,
|
|
74
|
-
field:
|
|
74
|
+
field: 'created_by',
|
|
75
75
|
},
|
|
76
|
-
as:
|
|
76
|
+
as: 'createdByUser',
|
|
77
77
|
});
|
|
78
78
|
UserPayoutModel.belongsTo(userModel_js_1.default, {
|
|
79
79
|
foreignKey: {
|
|
80
|
-
name:
|
|
80
|
+
name: 'updatedBy',
|
|
81
81
|
allowNull: true,
|
|
82
|
-
field:
|
|
82
|
+
field: 'updated_by',
|
|
83
83
|
},
|
|
84
|
-
as:
|
|
84
|
+
as: 'updatedByUser',
|
|
85
85
|
});
|
|
86
86
|
UserPayoutModel.belongsTo(userModel_js_1.default, {
|
|
87
87
|
foreignKey: {
|
|
88
|
-
name:
|
|
88
|
+
name: 'deletedBy',
|
|
89
89
|
allowNull: true,
|
|
90
|
-
field:
|
|
90
|
+
field: 'deleted_by',
|
|
91
91
|
},
|
|
92
|
-
as:
|
|
92
|
+
as: 'deletedByUser',
|
|
93
93
|
});
|
|
94
94
|
UserPayoutModel.belongsTo(instituteModel_js_1.default, {
|
|
95
95
|
foreignKey: {
|
|
96
|
-
name:
|
|
96
|
+
name: 'instituteId',
|
|
97
97
|
},
|
|
98
|
-
as:
|
|
98
|
+
as: 'institute',
|
|
99
99
|
});
|
|
100
100
|
instituteModel_js_1.default.hasMany(UserPayoutModel, {
|
|
101
101
|
foreignKey: {
|
|
102
|
-
name:
|
|
102
|
+
name: 'instituteId',
|
|
103
103
|
},
|
|
104
|
-
as:
|
|
104
|
+
as: 'instituteHasPayoutList',
|
|
105
105
|
});
|
|
106
106
|
UserPayoutModel.belongsTo(userModel_js_1.default, {
|
|
107
107
|
foreignKey: {
|
|
108
|
-
name:
|
|
108
|
+
name: 'userId',
|
|
109
109
|
},
|
|
110
|
-
as:
|
|
110
|
+
as: 'user',
|
|
111
111
|
});
|
|
112
112
|
userModel_js_1.default.hasMany(UserPayoutModel, {
|
|
113
113
|
foreignKey: {
|
|
114
|
-
name:
|
|
114
|
+
name: 'userId',
|
|
115
115
|
},
|
|
116
|
-
as:
|
|
116
|
+
as: 'userHasPayoutList',
|
|
117
117
|
});
|
|
118
118
|
const afterCreateOrUpdateHook = async (userPayout, user = null, transaction, filterOptions = {}) => {
|
|
119
119
|
try {
|
|
120
|
-
if (!userPayout.userPayoutDetailsList ||
|
|
121
|
-
!userPayout.userPayoutDetailsList.length)
|
|
120
|
+
if (!userPayout.userPayoutDetailsList || !userPayout.userPayoutDetailsList.length)
|
|
122
121
|
return userPayout;
|
|
123
|
-
userPayout.userPayoutDetailsList = (0, utils_js_1.getUniqueArrayByFields)(userPayout.userPayoutDetailsList, [
|
|
122
|
+
userPayout.userPayoutDetailsList = (0, utils_js_1.getUniqueArrayByFields)(userPayout.userPayoutDetailsList, ['subjectId']);
|
|
124
123
|
const options = {
|
|
125
124
|
transaction,
|
|
126
125
|
};
|
|
@@ -131,14 +130,10 @@ const afterCreateOrUpdateHook = async (userPayout, user = null, transaction, fil
|
|
|
131
130
|
let startOfPreviousMonth = (0, date_fns_1.startOfMonth)(previousMonthDate).toISOString();
|
|
132
131
|
let endOfPreviousMonth = (0, date_fns_1.endOfMonth)(previousMonthDate).toISOString();
|
|
133
132
|
if (filterOptions.include) {
|
|
134
|
-
filterOptions.include = !Array.isArray(filterOptions.include)
|
|
135
|
-
|
|
136
|
-
: filterOptions.include;
|
|
137
|
-
const historyListInclude = filterOptions.include.find((include) => include.as === "userPayoutHistoryList");
|
|
133
|
+
filterOptions.include = !Array.isArray(filterOptions.include) ? [filterOptions.include] : filterOptions.include;
|
|
134
|
+
const historyListInclude = filterOptions.include.find((include) => include.as === 'userPayoutHistoryList');
|
|
138
135
|
let where = {};
|
|
139
|
-
if (historyListInclude &&
|
|
140
|
-
historyListInclude.where &&
|
|
141
|
-
historyListInclude.where[sequelize_1.Op.and]) {
|
|
136
|
+
if (historyListInclude && historyListInclude.where && historyListInclude.where[sequelize_1.Op.and]) {
|
|
142
137
|
where = historyListInclude.where[sequelize_1.Op.and].pop();
|
|
143
138
|
}
|
|
144
139
|
if (where.payout_start_time && where.payout_end_time) {
|
|
@@ -146,13 +141,10 @@ const afterCreateOrUpdateHook = async (userPayout, user = null, transaction, fil
|
|
|
146
141
|
endOfPreviousMonth = where.payout_end_time[sequelize_1.Op.lte];
|
|
147
142
|
}
|
|
148
143
|
}
|
|
149
|
-
const attendanceWhereAnd = [
|
|
150
|
-
{ date: { $gte: startOfPreviousMonth } },
|
|
151
|
-
{ date: { $lte: endOfPreviousMonth } },
|
|
152
|
-
];
|
|
144
|
+
const attendanceWhereAnd = [{ date: { $gte: startOfPreviousMonth } }, { date: { $lte: endOfPreviousMonth } }];
|
|
153
145
|
const exsitUserPayout = (await UserPayoutModel.findOne({
|
|
154
146
|
where: { id: userPayout.id },
|
|
155
|
-
include: [{ association:
|
|
147
|
+
include: [{ association: 'userPayoutDetailsList' }],
|
|
156
148
|
transaction,
|
|
157
149
|
}));
|
|
158
150
|
if (!exsitUserPayout)
|
|
@@ -162,24 +154,23 @@ const afterCreateOrUpdateHook = async (userPayout, user = null, transaction, fil
|
|
|
162
154
|
where: {
|
|
163
155
|
instituteId: exsitUserPayout.instituteId,
|
|
164
156
|
subjectId: {
|
|
165
|
-
[sequelize_1.Op.in]: userPayout.userPayoutDetailsList.map(
|
|
157
|
+
[sequelize_1.Op.in]: userPayout.userPayoutDetailsList.map(userPayoutDetails => userPayoutDetails.subjectId),
|
|
166
158
|
},
|
|
167
159
|
},
|
|
168
160
|
attributes: [
|
|
169
|
-
[
|
|
170
|
-
[sequelize_1.Sequelize.fn(
|
|
161
|
+
['subject_id', 'subjectId'],
|
|
162
|
+
[sequelize_1.Sequelize.fn('sum', sequelize_1.Sequelize.col('amount')), 'amount'],
|
|
171
163
|
],
|
|
172
|
-
group: [
|
|
164
|
+
group: ['subject_id', 'created_at'],
|
|
173
165
|
raw: true,
|
|
174
166
|
});
|
|
175
167
|
feeTotalBySubjectList = JSON.parse(JSON.stringify(feeTotalBySubjectList));
|
|
176
|
-
userPayout.userPayoutDetailsList = userPayout.userPayoutDetailsList.map(
|
|
168
|
+
userPayout.userPayoutDetailsList = userPayout.userPayoutDetailsList.map(oneUserPayoutDetails => {
|
|
177
169
|
oneUserPayoutDetails.payableAmount = feeTotalBySubjectList
|
|
178
|
-
.filter(
|
|
170
|
+
.filter(feeTotalBySubject => feeTotalBySubject.subjectId === oneUserPayoutDetails.subjectId)
|
|
179
171
|
.reduce((sum, record) => {
|
|
180
172
|
if (oneUserPayoutDetails.percentage) {
|
|
181
|
-
const amount = ((record.amount || 0) * oneUserPayoutDetails.percentage) /
|
|
182
|
-
100;
|
|
173
|
+
const amount = ((record.amount || 0) * oneUserPayoutDetails.percentage) / 100;
|
|
183
174
|
return sum + parseFloat(amount.toFixed(2)); // Add fixed precision and convert back to number
|
|
184
175
|
}
|
|
185
176
|
return sum;
|
|
@@ -192,29 +183,25 @@ const afterCreateOrUpdateHook = async (userPayout, user = null, transaction, fil
|
|
|
192
183
|
where: {
|
|
193
184
|
instituteId: exsitUserPayout.instituteId,
|
|
194
185
|
subject: {
|
|
195
|
-
[sequelize_1.Op.in]: userPayout.userPayoutDetailsList.map(
|
|
186
|
+
[sequelize_1.Op.in]: userPayout.userPayoutDetailsList.map(userPayoutDetails => userPayoutDetails.subjectId),
|
|
196
187
|
},
|
|
197
|
-
[sequelize_1.Op.or]: [
|
|
198
|
-
{ primaryUserId: exsitUserPayout.userId },
|
|
199
|
-
{ secondaryUserId: exsitUserPayout.userId },
|
|
200
|
-
],
|
|
188
|
+
[sequelize_1.Op.or]: [{ primaryUserId: exsitUserPayout.userId }, { secondaryUserId: exsitUserPayout.userId }],
|
|
201
189
|
},
|
|
202
|
-
include: [{ association:
|
|
190
|
+
include: [{ association: 'workingDay' }],
|
|
203
191
|
}));
|
|
204
192
|
lectureList = JSON.parse(JSON.stringify(lectureList));
|
|
205
193
|
const currentMonthAttendenceList = await attendanceModel_js_1.default.find({
|
|
206
194
|
$and: attendanceWhereAnd,
|
|
207
195
|
userType: userPayout.userType,
|
|
208
|
-
|
|
209
|
-
|
|
196
|
+
'users.userId': userPayout.userId,
|
|
197
|
+
'users.status': { $ne: app_js_1.ATTENDANCE_STATUS.ABSENT },
|
|
210
198
|
});
|
|
211
|
-
userPayout.userPayoutDetailsList = userPayout.userPayoutDetailsList.map(
|
|
199
|
+
userPayout.userPayoutDetailsList = userPayout.userPayoutDetailsList.map(oneUserPayoutDetails => {
|
|
212
200
|
let totalMinutes = 0;
|
|
213
|
-
currentMonthAttendenceList.forEach(
|
|
214
|
-
const dayName = (0, date_fns_1.format)(attendance.date,
|
|
215
|
-
const attendanceDayLectureBySubjectList = lectureList.filter(
|
|
216
|
-
return
|
|
217
|
-
lecture.subject === oneUserPayoutDetails.subjectId);
|
|
201
|
+
currentMonthAttendenceList.forEach(attendance => {
|
|
202
|
+
const dayName = (0, date_fns_1.format)(attendance.date, 'EEEE');
|
|
203
|
+
const attendanceDayLectureBySubjectList = lectureList.filter(lecture => {
|
|
204
|
+
return lecture.workingDay.dayName === dayName && lecture.subject === oneUserPayoutDetails.subjectId;
|
|
218
205
|
});
|
|
219
206
|
if (attendanceDayLectureBySubjectList.length) {
|
|
220
207
|
totalMinutes += attendanceDayLectureBySubjectList.reduce((sum, record) => {
|
|
@@ -222,8 +209,7 @@ const afterCreateOrUpdateHook = async (userPayout, user = null, transaction, fil
|
|
|
222
209
|
}, 0);
|
|
223
210
|
}
|
|
224
211
|
});
|
|
225
|
-
oneUserPayoutDetails.payableAmount =
|
|
226
|
-
((oneUserPayoutDetails.amountPerHour || 0) / app_js_1.SIXTY) * totalMinutes;
|
|
212
|
+
oneUserPayoutDetails.payableAmount = ((oneUserPayoutDetails.amountPerHour || 0) / app_js_1.SIXTY) * totalMinutes;
|
|
227
213
|
return oneUserPayoutDetails;
|
|
228
214
|
});
|
|
229
215
|
}
|
|
@@ -233,9 +219,8 @@ const afterCreateOrUpdateHook = async (userPayout, user = null, transaction, fil
|
|
|
233
219
|
userPayoutDetails.userId = exsitUserPayout.userId;
|
|
234
220
|
userPayoutDetails.instituteId = exsitUserPayout.instituteId;
|
|
235
221
|
userPayoutDetails.type = exsitUserPayout.type;
|
|
236
|
-
const found = exsitUserPayout.userPayoutDetailsList.find(
|
|
237
|
-
userPayoutDetails.instituteId ===
|
|
238
|
-
exsitUserPayoutDetails.instituteId &&
|
|
222
|
+
const found = exsitUserPayout.userPayoutDetailsList.find(exsitUserPayoutDetails => userPayoutDetails.userPayoutId === exsitUserPayout.id &&
|
|
223
|
+
userPayoutDetails.instituteId === exsitUserPayoutDetails.instituteId &&
|
|
239
224
|
userPayoutDetails.userId === exsitUserPayoutDetails.userId &&
|
|
240
225
|
userPayoutDetails.type === exsitUserPayoutDetails.type &&
|
|
241
226
|
userPayoutDetails.subjectId === exsitUserPayoutDetails.subjectId &&
|
|
@@ -255,7 +240,7 @@ const afterCreateOrUpdateHook = async (userPayout, user = null, transaction, fil
|
|
|
255
240
|
await userPayoutDetailsModel_js_1.default.destroy({
|
|
256
241
|
where: {
|
|
257
242
|
id: {
|
|
258
|
-
[sequelize_1.Op.notIn]: userPayoutDetailsList.map(
|
|
243
|
+
[sequelize_1.Op.notIn]: userPayoutDetailsList.map(userPayoutDetails => userPayoutDetails.id),
|
|
259
244
|
},
|
|
260
245
|
userPayoutId: exsitUserPayout.id,
|
|
261
246
|
},
|
|
@@ -289,7 +274,7 @@ const afterFindHook = async (userPayoutList, options = {}) => {
|
|
|
289
274
|
updatedData.push(syncUserPayout);
|
|
290
275
|
}
|
|
291
276
|
userPayoutList = userPayoutList.map((userPayout) => {
|
|
292
|
-
const found = updatedData.find(
|
|
277
|
+
const found = updatedData.find(one => one.id === userPayout.id);
|
|
293
278
|
if (found) {
|
|
294
279
|
userPayout.totalPayableAmount = found.totalPayableAmount;
|
|
295
280
|
userPayout.userPayoutDetailsList = found.userPayoutDetailsList;
|
|
@@ -305,7 +290,7 @@ const afterFindHook = async (userPayoutList, options = {}) => {
|
|
|
305
290
|
return userPayoutList;
|
|
306
291
|
}
|
|
307
292
|
};
|
|
308
|
-
UserPayoutModel.addHook(
|
|
293
|
+
UserPayoutModel.addHook('afterFind', async (result, options) => {
|
|
309
294
|
if (options.syncUserPayoutLastCalculatedAt && Array.isArray(result)) {
|
|
310
295
|
result = (await afterFindHook(result, options));
|
|
311
296
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FilterQuery, UpdateQuery, Document, QueryOptions, Model as MongooseModel, PopulateOptions, MongooseUpdateQueryOptions, UpdateWriteOpResult, ClientSession, CreateOptions } from
|
|
2
|
-
import { TPaginationOptions } from
|
|
3
|
-
import { IMongooseCommonService } from
|
|
4
|
-
import { PipelineStage } from
|
|
1
|
+
import { FilterQuery, UpdateQuery, Document, QueryOptions, Model as MongooseModel, PopulateOptions, MongooseUpdateQueryOptions, UpdateWriteOpResult, ClientSession, CreateOptions } from 'mongoose';
|
|
2
|
+
import { TPaginationOptions } from '../../types/commonType.js';
|
|
3
|
+
import { IMongooseCommonService } from '../Contracts/IMongooseCommonService.js';
|
|
4
|
+
import { PipelineStage } from 'mongoose';
|
|
5
5
|
export declare class MongooseCommonService<T extends Document> implements IMongooseCommonService<T> {
|
|
6
6
|
private model;
|
|
7
7
|
constructor(model: MongooseModel<T>);
|
|
@@ -30,7 +30,7 @@ class MongooseCommonService {
|
|
|
30
30
|
const convertOrderToSort = (order) => {
|
|
31
31
|
const sort = {};
|
|
32
32
|
for (const [key, direction] of order) {
|
|
33
|
-
sort[key] = direction.toUpperCase() ===
|
|
33
|
+
sort[key] = direction.toUpperCase() === 'DESC' ? -1 : 1;
|
|
34
34
|
}
|
|
35
35
|
return sort;
|
|
36
36
|
};
|
|
@@ -98,9 +98,7 @@ class MongooseCommonService {
|
|
|
98
98
|
}), options);
|
|
99
99
|
}
|
|
100
100
|
async delete(filter, options = {}) {
|
|
101
|
-
return this.model
|
|
102
|
-
.updateMany(filter, { deletedBy: options.userId, deletedAt: new Date() }, options)
|
|
103
|
-
.exec();
|
|
101
|
+
return this.model.updateMany(filter, { deletedBy: options.userId, deletedAt: new Date() }, options).exec();
|
|
104
102
|
}
|
|
105
103
|
async aggregate(pipeline) {
|
|
106
104
|
return this.model.aggregate(pipeline).exec();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FilterQuery, UpdateQuery, Document, QueryOptions, PopulateOptions, MongooseUpdateQueryOptions, UpdateWriteOpResult, ClientSession, CreateOptions } from
|
|
2
|
-
import { TPaginationOptions } from
|
|
1
|
+
import { FilterQuery, UpdateQuery, Document, QueryOptions, PopulateOptions, MongooseUpdateQueryOptions, UpdateWriteOpResult, ClientSession, CreateOptions } from 'mongoose';
|
|
2
|
+
import { TPaginationOptions } from '../../types/commonType.js';
|
|
3
3
|
interface IReadService<T extends Document> {
|
|
4
4
|
findAll(filter: FilterQuery<T>, options?: QueryOptions, populate?: PopulateOptions | PopulateOptions[]): Promise<T[]>;
|
|
5
5
|
findOne(filter: FilterQuery<T>, options?: QueryOptions, populate?: PopulateOptions | PopulateOptions[]): Promise<T | null>;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { FindOptions, WhereOptions, UpdateOptions, BulkCreateOptions, DestroyOptions, CreateOptions, Identifier, Model, UpsertOptions, CountOptions } from
|
|
2
|
-
import { TPaginationOptions } from
|
|
1
|
+
import { FindOptions, WhereOptions, UpdateOptions, BulkCreateOptions, DestroyOptions, CreateOptions, Identifier, Model, UpsertOptions, CountOptions } from 'sequelize';
|
|
2
|
+
import { TPaginationOptions } from '../../types/commonType.js';
|
|
3
3
|
interface IReadService<T extends Model> {
|
|
4
|
-
findAll(where: WhereOptions<T[
|
|
5
|
-
findOne(where: WhereOptions<T[
|
|
6
|
-
findByPk(identifier: Identifier, options?: FindOptions<T[
|
|
7
|
-
findAllWithPagination(where: WhereOptions<T[
|
|
8
|
-
count(where: WhereOptions<T[
|
|
4
|
+
findAll(where: WhereOptions<T['_attributes']>, options?: FindOptions<T['_attributes']>): Promise<T['_attributes'][]>;
|
|
5
|
+
findOne(where: WhereOptions<T['_attributes']>, options?: FindOptions<T['_attributes']>): Promise<T['_attributes'] | null>;
|
|
6
|
+
findByPk(identifier: Identifier, options?: FindOptions<T['_attributes']>): Promise<T['_attributes'] | null>;
|
|
7
|
+
findAllWithPagination(where: WhereOptions<T['_attributes']>, options?: FindOptions<T['_attributes']>): Promise<TPaginationOptions<T['_attributes']>>;
|
|
8
|
+
count(where: WhereOptions<T['_attributes']>, options?: CountOptions<T['_attributes']>): Promise<number>;
|
|
9
9
|
}
|
|
10
10
|
interface IWriteService<T extends Model> {
|
|
11
|
-
update(where: WhereOptions<T[
|
|
12
|
-
upsert(conflictWhere: WhereOptions<T[
|
|
13
|
-
create(createData: T[
|
|
14
|
-
bulkCreate(createData: T[
|
|
11
|
+
update(where: WhereOptions<T['_attributes']>, updateData: Partial<T['_attributes']>, options?: Partial<UpdateOptions>): Promise<[number]>;
|
|
12
|
+
upsert(conflictWhere: WhereOptions<T['_attributes']>, updateData: T['_creationAttributes'], options?: Partial<UpsertOptions>): Promise<[T['_attributes'], boolean | null]>;
|
|
13
|
+
create(createData: T['_creationAttributes'], options?: CreateOptions): Promise<T['_attributes']>;
|
|
14
|
+
bulkCreate(createData: T['_creationAttributes'][], options?: BulkCreateOptions<T['_attributes']>): Promise<T['_attributes'][]>;
|
|
15
15
|
}
|
|
16
16
|
interface IDeleteService<T extends Model> {
|
|
17
|
-
delete(where: WhereOptions<T[
|
|
17
|
+
delete(where: WhereOptions<T['_attributes']>, options?: DestroyOptions<T['_attributes']>): Promise<number>;
|
|
18
18
|
}
|
|
19
19
|
export interface ISequelizeCommonService<T extends Model> extends IReadService<T>, IWriteService<T>, IDeleteService<T> {
|
|
20
20
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IGenarateIdCardModelAttributes } from
|
|
2
|
-
export type TGenarateIdCardModelAttributes = Omit<IGenarateIdCardModelAttributes,
|
|
1
|
+
import { IGenarateIdCardModelAttributes } from '../interfaces/generateIdCardInterface.js';
|
|
2
|
+
export type TGenarateIdCardModelAttributes = Omit<IGenarateIdCardModelAttributes, 'id'>;
|
package/package.json
CHANGED
|
@@ -1,49 +1,51 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
"name": "@kipicore/dbcore",
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"clean": "rm -rf dist",
|
|
10
|
+
"format": "prettier . --write",
|
|
11
|
+
"prebuild": "node scripts/generate-index.js",
|
|
12
|
+
"build": "npm run clean && tsc -p tsconfig.json && npm run format"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"postgres",
|
|
16
|
+
"mongodb",
|
|
17
|
+
"sequelize",
|
|
18
|
+
"mongoose",
|
|
19
|
+
"database",
|
|
20
|
+
"core",
|
|
21
|
+
"typescript"
|
|
22
|
+
],
|
|
23
|
+
"author": "chetan godhani",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"private": false,
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@aws-sdk/client-s3": "^3.895.0",
|
|
28
|
+
"@aws-sdk/s3-request-presigner": "^3.895.0",
|
|
29
|
+
"axios": "^1.12.2",
|
|
30
|
+
"date-fns": "^4.1.0",
|
|
31
|
+
"dotenv": "^17.2.2",
|
|
32
|
+
"joi": "^18.0.1",
|
|
33
|
+
"mongoose": "^8.5.2",
|
|
34
|
+
"pg": "^8.12.0",
|
|
35
|
+
"sequelize": "^6.37.3",
|
|
36
|
+
"uuid": "^8.3.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/mongoose": "^5.11.97",
|
|
40
|
+
"@types/node": "^24.5.2",
|
|
41
|
+
"@types/sequelize": "^4.28.14",
|
|
42
|
+
"typescript": "^5.5.4",
|
|
43
|
+
"prettier": "^3.3.3"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20.16.0"
|
|
50
|
+
}
|
|
49
51
|
}
|