Skip to content

Commit

Permalink
Update search-filter-options.decorator.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
tacxou authored Sep 3, 2024
1 parent af8e58a commit 20a1bb2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/search-filter-schema/search-filter-options.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const DEFAULT_SEARCH_OPTIONS = {
skipKey: 'skip',
pageKey: 'page',
sortKey: 'sort',
allowUnlimited: false,
}

export interface FilterSearchOptions {
Expand All @@ -18,6 +19,7 @@ export interface FilterSearchOptions {
skipKey?: string
pageKey?: string
sortKey?: string
allowUnlimited?: boolean,
}

export interface SortOptions {
Expand Down Expand Up @@ -53,7 +55,8 @@ export function filterOptions(
options?: FilterSearchOptions,
): FilterOptions {
options = { ...DEFAULT_SEARCH_OPTIONS, ...options }
const limit = parseInt(`${queries[options.limitKey]}`) || options.defaultLimit
let limit = parseInt(`${queries[options.limitKey]}`) || options.defaultLimit
if (limit === -1 && options.allowUnlimited) limit = undefined
let skip = parseInt(`${queries[options.skipKey]}`) || 0

if (queries[options.pageKey]) {
Expand Down

0 comments on commit 20a1bb2

Please sign in to comment.