@eeplatform/basic-edu 1.4.2 → 1.4.3
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -203,7 +203,7 @@ declare function MLearner(value: TLearner): {
|
|
|
203
203
|
declare function useEnrollmentRepo(): {
|
|
204
204
|
createIndexes: () => Promise<void>;
|
|
205
205
|
add: (value: TLearner, session?: ClientSession) => Promise<ObjectId>;
|
|
206
|
-
getAll: ({ search, page, limit, sort, status, school, schoolYear, gradeLevelToEnroll, }?: {
|
|
206
|
+
getAll: ({ search, page, limit, sort, status, school, schoolYear, gradeLevelToEnroll, createdBy, }?: {
|
|
207
207
|
search?: string | undefined;
|
|
208
208
|
page?: number | undefined;
|
|
209
209
|
limit?: number | undefined;
|
|
@@ -212,6 +212,7 @@ declare function useEnrollmentRepo(): {
|
|
|
212
212
|
school?: string | undefined;
|
|
213
213
|
schoolYear?: string | undefined;
|
|
214
214
|
gradeLevelToEnroll?: string | undefined;
|
|
215
|
+
createdBy?: string | undefined;
|
|
215
216
|
}) => Promise<Record<string, any> | {
|
|
216
217
|
items: any[];
|
|
217
218
|
pages: number;
|
package/dist/index.js
CHANGED
|
@@ -2115,24 +2115,41 @@ function useEnrollmentRepo() {
|
|
|
2115
2115
|
status = "active",
|
|
2116
2116
|
school = "",
|
|
2117
2117
|
schoolYear = "",
|
|
2118
|
-
gradeLevelToEnroll = ""
|
|
2118
|
+
gradeLevelToEnroll = "",
|
|
2119
|
+
createdBy = ""
|
|
2119
2120
|
} = {}) {
|
|
2120
2121
|
page = page > 0 ? page - 1 : 0;
|
|
2121
2122
|
const query = {
|
|
2122
2123
|
status
|
|
2123
2124
|
};
|
|
2125
|
+
const cacheParams = {
|
|
2126
|
+
page,
|
|
2127
|
+
limit,
|
|
2128
|
+
sort: JSON.stringify(sort)
|
|
2129
|
+
};
|
|
2130
|
+
if (createdBy) {
|
|
2131
|
+
try {
|
|
2132
|
+
query.createdBy = new import_mongodb4.ObjectId(createdBy);
|
|
2133
|
+
cacheParams.createdBy = createdBy;
|
|
2134
|
+
} catch (error) {
|
|
2135
|
+
throw new import_nodejs_utils5.BadRequestError("Invalid createdBy ID.");
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2124
2138
|
if (school) {
|
|
2125
2139
|
try {
|
|
2126
2140
|
query.school = new import_mongodb4.ObjectId(school);
|
|
2141
|
+
cacheParams.school = school;
|
|
2127
2142
|
} catch (error) {
|
|
2128
2143
|
throw new import_nodejs_utils5.BadRequestError("Invalid school ID.");
|
|
2129
2144
|
}
|
|
2130
2145
|
}
|
|
2131
2146
|
if (schoolYear) {
|
|
2132
2147
|
query.schoolYear = schoolYear;
|
|
2148
|
+
cacheParams.schoolYear = schoolYear;
|
|
2133
2149
|
}
|
|
2134
2150
|
if (gradeLevelToEnroll) {
|
|
2135
2151
|
query.gradeLevelToEnroll = gradeLevelToEnroll;
|
|
2152
|
+
cacheParams.gradeLevelToEnroll = gradeLevelToEnroll;
|
|
2136
2153
|
}
|
|
2137
2154
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
2138
2155
|
if (search) {
|
|
@@ -2144,11 +2161,6 @@ function useEnrollmentRepo() {
|
|
|
2144
2161
|
{ gradeLevelToEnroll: { $regex: search, $options: "i" } }
|
|
2145
2162
|
];
|
|
2146
2163
|
}
|
|
2147
|
-
const cacheParams = {
|
|
2148
|
-
page,
|
|
2149
|
-
limit,
|
|
2150
|
-
sort: JSON.stringify(sort)
|
|
2151
|
-
};
|
|
2152
2164
|
if (search)
|
|
2153
2165
|
cacheParams.search = search;
|
|
2154
2166
|
if (status !== "active")
|
|
@@ -3046,7 +3058,8 @@ function useEnrollmentController() {
|
|
|
3046
3058
|
status: import_joi7.default.string().optional().allow("", null),
|
|
3047
3059
|
school: import_joi7.default.string().hex().optional().allow("", null),
|
|
3048
3060
|
schoolYear: import_joi7.default.string().optional().allow("", null),
|
|
3049
|
-
gradeLevelToEnroll: import_joi7.default.string().optional().allow("", null)
|
|
3061
|
+
gradeLevelToEnroll: import_joi7.default.string().optional().allow("", null),
|
|
3062
|
+
createdBy: import_joi7.default.string().hex().optional().allow("", null)
|
|
3050
3063
|
});
|
|
3051
3064
|
const { error } = validation.validate(query);
|
|
3052
3065
|
if (error) {
|
|
@@ -3058,6 +3071,7 @@ function useEnrollmentController() {
|
|
|
3058
3071
|
limit = isNaN(limit) ? 20 : limit;
|
|
3059
3072
|
const sort = req.query.sort ? String(req.query.sort).split(",") : "";
|
|
3060
3073
|
const sortOrder = req.query.sortOrder ? String(req.query.sortOrder).split(",") : "";
|
|
3074
|
+
const createdBy = req.query.createdBy ?? "";
|
|
3061
3075
|
const sortObj = {};
|
|
3062
3076
|
if (sort && sort.length > 0 && sortOrder && sortOrder.length > 0 && sort.length === sortOrder.length) {
|
|
3063
3077
|
for (let i = 0; i < sort.length; i++) {
|
|
@@ -3074,7 +3088,8 @@ function useEnrollmentController() {
|
|
|
3074
3088
|
status: req.query.status,
|
|
3075
3089
|
school: req.query.school,
|
|
3076
3090
|
schoolYear: req.query.schoolYear,
|
|
3077
|
-
gradeLevelToEnroll: req.query.gradeLevelToEnroll
|
|
3091
|
+
gradeLevelToEnroll: req.query.gradeLevelToEnroll,
|
|
3092
|
+
createdBy
|
|
3078
3093
|
});
|
|
3079
3094
|
res.json(result);
|
|
3080
3095
|
return;
|