Skip to content

Commit

Permalink
feat: add sort order enum
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelTshDev committed Mar 28, 2024
1 parent 5435e3d commit be78e43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions shared/constants/sort-order.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum SortOrder {
ASC,
DESC,
}
3 changes: 2 additions & 1 deletion shared/pagination-utils/pagination-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FindManyOptions, FindOperator, FindOptionsOrder, FindOptionsWhere, ObjectLiteral, Repository } from "typeorm";
import { SortOrder } from "../constants/sort-order.enum";

export interface PaginationResult<T> {
meta: {
Expand All @@ -23,7 +24,7 @@ export interface PaginationParamsDto {
search?: string;
}

type QueryFilters = { [key: string]: "ASC" | "DESC" } | { [key: string]: string | string[] };
type QueryFilters = { [key: string]: SortOrder } | { [key: string]: string | string[] };

export function calculateSkipFindOption(page: number, limit: number): number {
return (page - 1) * limit;
Expand Down

0 comments on commit be78e43

Please sign in to comment.