Comparing version
@@ -49,2 +49,11 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -317,20 +326,22 @@ exports.AgActivityBase = void 0; | ||
table.prototype.aggregate = function (filter, paging, order) { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, _b, pageIndex, _c, pageSize, _d, orderby, desc, cursor; | ||
var _e, _f; | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
var _c, _d, pageIndex, _e, pageSize, _f, orderby, desc, data, count; | ||
var _g, _h; | ||
return __generator(this, function (_j) { | ||
switch (_j.label) { | ||
case 0: | ||
_a = paging !== null && paging !== void 0 ? paging : {}, _b = _a.pageIndex, pageIndex = _b === void 0 ? 0 : _b, _c = _a.pageSize, pageSize = _c === void 0 ? 10 : _c; | ||
_d = order !== null && order !== void 0 ? order : {}, orderby = _d.orderby, desc = _d.desc; | ||
cursor = this.collection.aggregate(filter).skip(pageSize * pageIndex).limit(pageSize); | ||
_c = paging !== null && paging !== void 0 ? paging : {}, _d = _c.pageIndex, pageIndex = _d === void 0 ? 0 : _d, _e = _c.pageSize, pageSize = _e === void 0 ? 10 : _e; | ||
_f = order !== null && order !== void 0 ? order : {}, orderby = _f.orderby, desc = _f.desc; | ||
data = this.collection.aggregate(filter).skip(pageSize * pageIndex).limit(pageSize); | ||
if (orderby) | ||
cursor = cursor.sort((_e = {}, _e[orderby] = desc ? -1 : 1, _e)); | ||
_f = {}; | ||
return [4 /*yield*/, cursor.toArray()]; | ||
data = data.sort((_g = {}, _g[orderby] = desc ? -1 : 1, _g)); | ||
return [4 /*yield*/, this.collection.aggregate(__spreadArray(__spreadArray([], filter, true), [{ $count: "count" }], false)).toArray()]; | ||
case 1: | ||
_f.data = (_g.sent()); | ||
return [4 /*yield*/, this.collection.countDocuments(filter)]; | ||
case 2: return [2 /*return*/, (_f.total = _g.sent(), | ||
_f)]; | ||
count = _j.sent(); | ||
_h = {}; | ||
return [4 /*yield*/, data.toArray()]; | ||
case 2: return [2 /*return*/, (_h.data = (_j.sent()), | ||
_h.total = (_b = (_a = count[0]) === null || _a === void 0 ? void 0 : _a.count) !== null && _b !== void 0 ? _b : 0, | ||
_h)]; | ||
} | ||
@@ -337,0 +348,0 @@ }); |
{ | ||
"name": "ag-repo", | ||
"version": "1.0.198", | ||
"version": "1.0.199", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "", |
167875
0.37%3750
0.29%