c2-mongoose 2.1.442 → 2.1.443
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.
|
@@ -4,16 +4,14 @@ var SortV3FlowItem = /** @class */ (function () {
|
|
|
4
4
|
function SortV3FlowItem() {
|
|
5
5
|
}
|
|
6
6
|
SortV3FlowItem.prototype.execute = function (orderBy, orderSense) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return _a = {},
|
|
11
|
-
_a[order] = orderSense === "desc" ? -1 : 1,
|
|
12
|
-
_a;
|
|
13
|
-
});
|
|
7
|
+
var ordenation = orderBy.split(',').map(function (field) { return field.trim(); });
|
|
8
|
+
if (!ordenation.length) {
|
|
9
|
+
return [{ $sort: { _id: orderSense === "desc" ? -1 : 1 } }];
|
|
14
10
|
}
|
|
15
11
|
var sort = {};
|
|
16
|
-
|
|
12
|
+
ordenation.forEach(function (order) {
|
|
13
|
+
sort[order] = orderSense === "desc" ? -1 : 1;
|
|
14
|
+
});
|
|
17
15
|
return [{ $sort: sort }];
|
|
18
16
|
};
|
|
19
17
|
return SortV3FlowItem;
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
class SortV3FlowItem {
|
|
2
|
-
execute(orderBy: string
|
|
2
|
+
execute(orderBy: string, orderSense: string): any[] {
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
})
|
|
4
|
+
const ordenation = orderBy.split(',').map((field: string) => field.trim())
|
|
5
|
+
|
|
6
|
+
if (!ordenation.length) {
|
|
7
|
+
return [{ $sort: { _id: orderSense === "desc" ? -1 : 1 } }]
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const sort = {} as any
|
|
11
|
+
ordenation.forEach((order: string) => {
|
|
12
|
+
sort[order] = orderSense === "desc" ? -1 : 1
|
|
13
|
+
})
|
|
14
14
|
return [{ $sort: sort }]
|
|
15
15
|
}
|
|
16
16
|
}
|