docta-package 1.2.131 → 1.2.133
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.
|
@@ -7,8 +7,8 @@ const user_1 = require("./user");
|
|
|
7
7
|
// Base DTO for everyone
|
|
8
8
|
class SessionOutputDto {
|
|
9
9
|
constructor(session) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
this.id = (0, normalize_id_1.normalizeId)(session);
|
|
11
|
+
// (session.id ?? session._id)?.toString();
|
|
12
12
|
this.period = new period_1.PeriodOutputDto(session.period);
|
|
13
13
|
this.status = session.status;
|
|
14
14
|
this.doctorId =
|
|
@@ -8,17 +8,17 @@ const mongoose_1 = __importDefault(require("mongoose"));
|
|
|
8
8
|
function normalizeId(value) {
|
|
9
9
|
if (!value)
|
|
10
10
|
return null;
|
|
11
|
-
//
|
|
12
|
-
if (typeof value === "object" && value._id) {
|
|
13
|
-
return normalizeId(value._id);
|
|
14
|
-
}
|
|
15
|
-
// ObjectId
|
|
11
|
+
// 1️⃣ Raw ObjectId (aggregation, normal query)
|
|
16
12
|
if (value instanceof mongoose_1.default.Types.ObjectId) {
|
|
17
13
|
return value.toString();
|
|
18
14
|
}
|
|
19
|
-
//
|
|
15
|
+
// 2️⃣ Already a string
|
|
20
16
|
if (typeof value === "string") {
|
|
21
17
|
return value;
|
|
22
18
|
}
|
|
19
|
+
// 3️⃣ Populated document or plain object with _id
|
|
20
|
+
if (typeof value === "object" && value._id) {
|
|
21
|
+
return normalizeId(value._id);
|
|
22
|
+
}
|
|
23
23
|
return null;
|
|
24
24
|
}
|
package/package.json
CHANGED