@dnax/core 0.1.3 → 0.1.5
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/driver/mongo/utils.ts +14 -10
- package/lib/schema.ts +1 -1
- package/package.json +1 -1
package/driver/mongo/utils.ts
CHANGED
|
@@ -10,6 +10,20 @@ import { Cfg } from "../../config";
|
|
|
10
10
|
function buildPipeline(params: findParam, col?: Collection | undefined | null) {
|
|
11
11
|
let pipeline = [];
|
|
12
12
|
|
|
13
|
+
// sorted
|
|
14
|
+
if (!params?.$sort?.createdAt) {
|
|
15
|
+
pipeline.push({
|
|
16
|
+
$sort: {
|
|
17
|
+
...(params?.$sort || {}),
|
|
18
|
+
createdAt: -1,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
pipeline.push({
|
|
23
|
+
$sort: params?.$sort,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
13
27
|
// $match
|
|
14
28
|
if (params?.$match) {
|
|
15
29
|
pipeline.push({
|
|
@@ -110,16 +124,6 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
|
|
|
110
124
|
});
|
|
111
125
|
}
|
|
112
126
|
|
|
113
|
-
// sorted
|
|
114
|
-
if (!params?.$sort?.createdAt) {
|
|
115
|
-
pipeline.push({
|
|
116
|
-
$sort: {
|
|
117
|
-
...(params?.$sort || {}),
|
|
118
|
-
createdAt: -1,
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
127
|
// sample aleatoire
|
|
124
128
|
if (params?.$sample) {
|
|
125
129
|
pipeline.push({
|
package/lib/schema.ts
CHANGED
|
@@ -121,7 +121,7 @@ function buildSchema(col: Collection) {
|
|
|
121
121
|
|
|
122
122
|
if (!f?.validate?.schema) {
|
|
123
123
|
if (f?.nullable) {
|
|
124
|
-
propertySchema[f.name] = propertySchema[f.name];
|
|
124
|
+
propertySchema[f.name] = propertySchema[f.name].optional();
|
|
125
125
|
} else {
|
|
126
126
|
propertySchema[f.name] = propertySchema[f.name].required();
|
|
127
127
|
}
|