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
|
@ -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) {
|
||||
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