@dnax/core 0.1.4 → 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 -14
- 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,20 +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
|
-
} else {
|
|
122
|
-
pipeline.push({
|
|
123
|
-
$sort: params?.$sort,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
127
|
// sample aleatoire
|
|
128
128
|
if (params?.$sample) {
|
|
129
129
|
pipeline.push({
|