@grapi/server
Version:
Grapi Schema Generator For GraphQL Server
21 lines (20 loc) • 628 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sort = void 0;
const __1 = require("..");
const lodash_1 = require("../lodash");
const sort = (rows, order) => {
const orderFields = [];
const orderValues = [];
if ((0, lodash_1.isEmpty)(order)) {
return rows;
}
else {
(0, lodash_1.forEach)(order, (orderValue, fieldName) => {
orderFields.push(fieldName);
orderValues.push(orderValue === __1.OrderType.ASC ? `asc` : `desc`);
});
}
return (0, lodash_1.orderBy)(rows, orderFields, orderValues);
};
exports.sort = sort;