Skip to content

Commit

Permalink
fix: apply-sort should rely on apply-query-sort
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Oct 20, 2022
1 parent 044a151 commit dc7f713
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/query/parameter/sort/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SortDirection, SortParseOutput, parseQuerySort } from 'rapiq';
import { ObjectLiteral, SelectQueryBuilder } from 'typeorm';
import { buildKeyWithPrefix } from '../../utils';
import { SortApplyOptions, SortApplyOutput } from './type';

// --------------------------------------------------
Expand All @@ -21,8 +22,7 @@ export function applyQuerySortParseOutput<T extends ObjectLiteral = ObjectLitera
const sort : Record<string, `${SortDirection}`> = {};

for (let i = 0; i < data.length; i++) {
const prefix : string = data[i].path ? `${data[i].path}.` : '';
const key = `${prefix}${data[i].key}`;
const key = buildKeyWithPrefix(data[i].key, data[i].path);

sort[key] = data[i].value;
}
Expand Down Expand Up @@ -64,5 +64,5 @@ export function applySort<T extends ObjectLiteral = ObjectLiteral>(
data: unknown,
options?: SortApplyOptions<T>,
) : SortParseOutput {
return applyQuerySortParseOutput(query, parseQuerySort(data, options));
return applyQuerySort(query, data, options);
}

0 comments on commit dc7f713

Please sign in to comment.