Skip to content

Commit

Permalink
feat(supabase): add support for between in dataProvider. maps values …
Browse files Browse the repository at this point in the history
…to gte & lte. (#6206)

Co-authored-by: Ali Emir Şen <[email protected]>
  • Loading branch information
Sergio16T and aliemir authored Jul 30, 2024
1 parent 6927e15 commit 399ff2f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/hot-cougars-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/supabase": patch
---

feat: added support for between filter in supabase dataProvider. Maps values to gte & lte.

[Feat #6119](https://github.com/refinedev/refine/issues/6119)
9 changes: 9 additions & 0 deletions packages/supabase/src/utils/generateFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ export const generateFilter = (filter: CrudFilter, query: any) => {
return query.lt(filter.field, filter.value);
case "lte":
return query.lte(filter.field, filter.value);
case "between":
if (filter.value.length !== 2) {
throw new Error(
`[@refinedev/supabase]: Unexpected length ${filter.value.length}. Between operator expects a range between 2 values.`,
);
}
return query
.gte(filter.field, filter.value[0])
.lte(filter.field, filter.value[1]);
case "contains":
return query.ilike(filter.field, `%${filter.value}%`);
case "containss":
Expand Down

0 comments on commit 399ff2f

Please sign in to comment.