mirror of
https://github.com/vale981/grapher
synced 2025-03-06 01:51:38 -05:00
sorting must be done before limit!
This commit is contained in:
parent
55f593719f
commit
2b17c352ce
2 changed files with 7 additions and 6 deletions
|
@ -4,7 +4,7 @@ import ReducerNode from '../nodes/reducerNode.js';
|
|||
import dotize from './dotize.js';
|
||||
import createReducers from '../reducers/lib/createReducers';
|
||||
|
||||
const specialFields = ['$filters', '$options', '$postFilters','$postOptions','$postFilter']; //keep $postFilter for legacy support
|
||||
const specialFields = ['$filters', '$options', '$postFilters', '$postOptions', '$postFilter']; //keep $postFilter for legacy support
|
||||
|
||||
/**
|
||||
* Creates node objects from the body
|
||||
|
|
|
@ -39,14 +39,15 @@ export function applyPostFilters(node) {
|
|||
export function applyPostOptions(node) {
|
||||
const options = node.props.$postOptions;
|
||||
if (options) {
|
||||
if(options.limit || options.skip){
|
||||
const start = options.skip || 0, end = options.limit ? options.limit + start : -0;
|
||||
node.results = node.results.slice(start, end);
|
||||
}
|
||||
if(options.sort){
|
||||
if (options.sort) {
|
||||
const sorter = new Minimongo.Sorter(options.sort);
|
||||
node.results.sort(sorter.getComparator());
|
||||
}
|
||||
if (options.limit || options.skip) {
|
||||
const start = options.skip || 0;
|
||||
const end = options.limit ? options.limit + start : node.results.length;
|
||||
node.results = node.results.slice(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
node.collectionNodes.forEach(collectionNode => {
|
||||
|
|
Loading…
Add table
Reference in a new issue