Skip to content

Commit 61f1d2b

Browse files
filter undefied
1 parent 5e3ab93 commit 61f1d2b

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

src/common/pagination/pipes/pagination.filter-contain.pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function PaginationFilterContainPipe(
1616
{ data: field }: ArgumentMetadata
1717
): Promise<Record<string, { $regex: RegExp; $options: string }>> {
1818
if (!value) {
19-
return undefined;
19+
value = '';
2020
}
2121

2222
if (

src/common/pagination/pipes/pagination.filter-date.pipe.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ export function PaginationFilterDatePipe(
1919
value: string,
2020
{ data: field }: ArgumentMetadata
2121
): Promise<Record<string, Date>> {
22-
if (!value) {
23-
return undefined;
24-
}
25-
2622
let date: Date = this.helperDateService.create(value);
2723

2824
if (

src/common/pagination/pipes/pagination.filter-in-boolean.pipe.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@ export function PaginationFilterInBooleanPipe(
1717
value: string,
1818
{ data: field }: ArgumentMetadata
1919
): Promise<Record<string, { $in: boolean[] }>> {
20-
if (!value) {
21-
return undefined;
22-
}
20+
let finalValue: boolean[] = defaultValue as boolean[];
2321

24-
const val: boolean[] = value
25-
? this.helperArrayService.unique(
26-
value.split(',').map((val: string) => val === 'true')
27-
)
28-
: defaultValue;
22+
if (value) {
23+
finalValue = this.helperArrayService.unique(
24+
value.split(',').map((val: string) => val === 'true')
25+
);
26+
}
2927

30-
return this.paginationService.filterIn<boolean>(field, val);
28+
return this.paginationService.filterIn<boolean>(field, finalValue);
3129
}
3230
}
3331

src/common/pagination/pipes/pagination.filter-in-enum.pipe.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,16 @@ export function PaginationFilterInEnumPipe<T>(
1414
value: string,
1515
{ data: field }: ArgumentMetadata
1616
): Promise<Record<string, { $in: T[] }>> {
17-
if (!value) {
18-
return undefined;
19-
}
17+
let finalValue: T[] = defaultValue as T[];
2018

21-
const val: T[] = value
22-
? (value
23-
.split(',')
24-
.map((val: string) => defaultEnum[val])
25-
.filter((val: string) => val) as T[])
26-
: (defaultValue as T[]);
19+
if (value) {
20+
finalValue = value
21+
.split(',')
22+
.map((val: string) => defaultEnum[val])
23+
.filter((val: string) => val) as T[];
24+
}
2725

28-
return this.paginationService.filterIn<T>(field, val);
26+
return this.paginationService.filterIn<T>(field, finalValue);
2927
}
3028
}
3129

0 commit comments

Comments
 (0)