Skip to content

Commit

Permalink
Merge pull request #21 from ArthurMJ96/fix-20
Browse files Browse the repository at this point in the history
fix #20
  • Loading branch information
david-plugge authored Oct 24, 2023
2 parents 2f60d38 + bbadb7c commit 5f1b0b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-years-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'typed-pocketbase': patch
---

Fix: Filter with empty and()/or() results in Invalid filter parameters.
10 changes: 3 additions & 7 deletions src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,15 @@ export function and<T extends BaseRecord>(
...filters: Filter<T>[]
): FilterParam<T> {
const str = serializeFilters(filters).join(' && ');

if (!str.length) return ''
return `(${str})`;
}

export function or<T extends BaseRecord>(
...filters: Filter<T>[]
): FilterParam<T> {
const str = filters
.filter(Boolean)
.map((filter) =>
Array.isArray(filter) ? serializeFilter(filter) : filter
)
.join(' || ');
const str = serializeFilters(filters).join(' || ');
if (!str.length) return ''
return `(${str})`;
}

Expand Down

0 comments on commit 5f1b0b8

Please sign in to comment.