@akanjs/server 0.9.39 → 0.9.40
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/cjs/src/schema.js +8 -13
- package/esm/src/schema.js +9 -23
- package/package.json +1 -1
package/cjs/src/schema.js
CHANGED
|
@@ -71,12 +71,12 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
71
71
|
}
|
|
72
72
|
prop = { type: (0, import_base.arraiedModel)(prop, fieldMeta.optArrDepth), default: [], required: true };
|
|
73
73
|
if (fieldMeta.modelRef.prototype === Date.prototype) {
|
|
74
|
-
prop.get = (dates) =>
|
|
75
|
-
prop.set = (days) =>
|
|
74
|
+
prop.get = (dates) => dates.map((date) => (0, import_base.dayjs)(date));
|
|
75
|
+
prop.set = (days) => days.map((day) => day.toDate());
|
|
76
76
|
}
|
|
77
77
|
if (fieldMeta.isClass && !fieldMeta.isScalar || fieldMeta.modelRef.prototype === import_base.ID.prototype) {
|
|
78
|
-
prop.get = (ids) =>
|
|
79
|
-
prop.set = (ids) =>
|
|
78
|
+
prop.get = (ids) => ids.map((id) => id.toString());
|
|
79
|
+
prop.set = (ids) => ids.map((id) => new import_mongoose.Types.ObjectId(id));
|
|
80
80
|
}
|
|
81
81
|
} else {
|
|
82
82
|
prop.type = (0, import_base.arraiedModel)(type, fieldMeta.arrDepth);
|
|
@@ -118,17 +118,12 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
118
118
|
prop.set = (v) => v === null ? void 0 : v;
|
|
119
119
|
}
|
|
120
120
|
if (fieldMeta.modelRef.prototype === Date.prototype) {
|
|
121
|
-
prop.get = (date) =>
|
|
122
|
-
prop.set = (day) =>
|
|
121
|
+
prop.get = (date) => date ? (0, import_base.dayjs)(date) : void 0;
|
|
122
|
+
prop.set = (day) => day ? (0, import_base.dayjs)(day).toDate() : void 0;
|
|
123
123
|
}
|
|
124
124
|
if (fieldMeta.isClass && !fieldMeta.isScalar || fieldMeta.modelRef.prototype === import_base.ID.prototype) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
prop.set = (id) => id ? new import_mongoose.Types.ObjectId(id) : void 0;
|
|
128
|
-
} else {
|
|
129
|
-
prop.get = (val) => (0, import_base.applyFnToArrayObjects)(val, (id) => id ? id.toString() : void 0);
|
|
130
|
-
prop.set = (val) => (0, import_base.applyFnToArrayObjects)(val, (id) => id ? new import_mongoose.Types.ObjectId(id) : void 0);
|
|
131
|
-
}
|
|
125
|
+
prop.get = (id) => id ? id.toString() : void 0;
|
|
126
|
+
prop.set = (id) => id ? new import_mongoose.Types.ObjectId(id) : void 0;
|
|
132
127
|
}
|
|
133
128
|
if (fieldMeta.isClass && fieldMeta.isScalar && fieldMeta.default === null && !fieldMeta.nullable) {
|
|
134
129
|
prop.default = (0, import_signal.makeDefault)(fieldMeta.modelRef);
|
package/esm/src/schema.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
applyFnToArrayObjects,
|
|
3
|
-
arraiedModel,
|
|
4
|
-
dayjs,
|
|
5
|
-
Enum,
|
|
6
|
-
Float,
|
|
7
|
-
ID,
|
|
8
|
-
Int,
|
|
9
|
-
JSON
|
|
10
|
-
} from "@akanjs/base";
|
|
1
|
+
import { arraiedModel, dayjs, Enum, Float, ID, Int, JSON } from "@akanjs/base";
|
|
11
2
|
import { isDayjs } from "@akanjs/common";
|
|
12
3
|
import { getClassMeta, getFieldMetas, getFullModelRef, getInputModelRef } from "@akanjs/constant";
|
|
13
4
|
import { getDefaultSchemaOptions, ObjectId } from "@akanjs/document";
|
|
@@ -57,12 +48,12 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
57
48
|
}
|
|
58
49
|
prop = { type: arraiedModel(prop, fieldMeta.optArrDepth), default: [], required: true };
|
|
59
50
|
if (fieldMeta.modelRef.prototype === Date.prototype) {
|
|
60
|
-
prop.get = (dates) =>
|
|
61
|
-
prop.set = (days) =>
|
|
51
|
+
prop.get = (dates) => dates.map((date) => dayjs(date));
|
|
52
|
+
prop.set = (days) => days.map((day) => day.toDate());
|
|
62
53
|
}
|
|
63
54
|
if (fieldMeta.isClass && !fieldMeta.isScalar || fieldMeta.modelRef.prototype === ID.prototype) {
|
|
64
|
-
prop.get = (ids) =>
|
|
65
|
-
prop.set = (ids) =>
|
|
55
|
+
prop.get = (ids) => ids.map((id) => id.toString());
|
|
56
|
+
prop.set = (ids) => ids.map((id) => new Types.ObjectId(id));
|
|
66
57
|
}
|
|
67
58
|
} else {
|
|
68
59
|
prop.type = arraiedModel(type, fieldMeta.arrDepth);
|
|
@@ -104,17 +95,12 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
104
95
|
prop.set = (v) => v === null ? void 0 : v;
|
|
105
96
|
}
|
|
106
97
|
if (fieldMeta.modelRef.prototype === Date.prototype) {
|
|
107
|
-
prop.get = (date) =>
|
|
108
|
-
prop.set = (day) =>
|
|
98
|
+
prop.get = (date) => date ? dayjs(date) : void 0;
|
|
99
|
+
prop.set = (day) => day ? dayjs(day).toDate() : void 0;
|
|
109
100
|
}
|
|
110
101
|
if (fieldMeta.isClass && !fieldMeta.isScalar || fieldMeta.modelRef.prototype === ID.prototype) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
prop.set = (id) => id ? new Types.ObjectId(id) : void 0;
|
|
114
|
-
} else {
|
|
115
|
-
prop.get = (val) => applyFnToArrayObjects(val, (id) => id ? id.toString() : void 0);
|
|
116
|
-
prop.set = (val) => applyFnToArrayObjects(val, (id) => id ? new Types.ObjectId(id) : void 0);
|
|
117
|
-
}
|
|
102
|
+
prop.get = (id) => id ? id.toString() : void 0;
|
|
103
|
+
prop.set = (id) => id ? new Types.ObjectId(id) : void 0;
|
|
118
104
|
}
|
|
119
105
|
if (fieldMeta.isClass && fieldMeta.isScalar && fieldMeta.default === null && !fieldMeta.nullable) {
|
|
120
106
|
prop.default = makeDefault(fieldMeta.modelRef);
|