@dnax/core 0.8.11 → 0.8.13
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/define/index.ts +2 -0
- package/driver/mongo/rest.ts +8 -2
- package/lib/collection.ts +2 -0
- package/lib/schema.ts +6 -1
- package/package.json +1 -1
package/define/index.ts
CHANGED
package/driver/mongo/rest.ts
CHANGED
|
@@ -723,7 +723,10 @@ class useRest {
|
|
|
723
723
|
update = omit(update, omitUpdate);
|
|
724
724
|
|
|
725
725
|
if (update?.$set) {
|
|
726
|
-
update.$set = deepSetId(
|
|
726
|
+
update.$set = deepSetId(
|
|
727
|
+
col,
|
|
728
|
+
omit(update.$set, ["createdAt", "updatedAt"])
|
|
729
|
+
);
|
|
727
730
|
update.$set = transformAllDate(update.$set);
|
|
728
731
|
update.$set = await hashPasswordAuto(update.$set, col);
|
|
729
732
|
// data = transformAllDate(data);
|
|
@@ -973,7 +976,10 @@ class useRest {
|
|
|
973
976
|
update = omit(update, omitUpdate);
|
|
974
977
|
|
|
975
978
|
if (update.$set) {
|
|
976
|
-
update.$set = deepSetId(
|
|
979
|
+
update.$set = deepSetId(
|
|
980
|
+
col,
|
|
981
|
+
omit(update.$set, ["createdAt", "updatedAt"])
|
|
982
|
+
);
|
|
977
983
|
update.$set = transformAllDate(update.$set);
|
|
978
984
|
update.$set = await hashPasswordAuto(update.$set, col);
|
|
979
985
|
var { valid, output, error } = this.validator(
|
package/lib/collection.ts
CHANGED
package/lib/schema.ts
CHANGED
|
@@ -4,6 +4,11 @@ import v, { type AnySchema } from "joi";
|
|
|
4
4
|
function buildSchema(col: Collection) {
|
|
5
5
|
let propertySchema = {} as { [key: string]: AnySchema };
|
|
6
6
|
|
|
7
|
+
if (col?.timestamps) {
|
|
8
|
+
propertySchema["createdAt"] = v.date();
|
|
9
|
+
propertySchema["updatedAt"] = v.date();
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
if (col?.media) {
|
|
8
13
|
propertySchema["_file"] = v.object();
|
|
9
14
|
}
|
|
@@ -134,7 +139,7 @@ function buildSchema(col: Collection) {
|
|
|
134
139
|
}
|
|
135
140
|
});
|
|
136
141
|
|
|
137
|
-
let buildSchema = v.object(propertySchema)
|
|
142
|
+
let buildSchema = v.object(propertySchema);
|
|
138
143
|
|
|
139
144
|
return buildSchema;
|
|
140
145
|
}
|