The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Rewrite Component for CommonFilters
Angelicoa03890da3e65
diff --git a/web/docs/common/CommonFilters.js b/web/docs/common/CommonFilters.jsnew file mode 100644index 00000000000..d90963d3866--- /dev/null+++ b/web/docs/common/CommonFilters.js@@ -0,0 +1,35 @@+import React from 'react'+import Filter from './filters/filter.mdx'+import Match from './filters/match.mdx'+import Eq from './filters/eq.mdx'+import Gt from './filters/gt.mdx'+import Lt from './filters/lt.mdx'+import Gte from './filters/gte.mdx'+import Lte from './filters/lte.mdx'+import Like from './filters/like.mdx'+import Ilike from './filters/ilike.mdx'+import Is from './filters/is.mdx'+import In from './filters/in.mdx'+import Not from './filters/not.mdx'++const filters = {+ filter: <Filter />,+ match: <Match />,+ eq: <Eq />,+ gt: <Gt />,+ lt: <Lt />,+ gte: <Gte />,+ lte: <Lte />,+ like: <Like />,+ ilike: <Ilike />,+ is: <Is />,+ in: <In />,+ not: <Not />,+}++function CommonFilters(props) {+ var filter = props.filter.toLowerCase()+ return filters[filter]+}++export default CommonFiltersdiff --git a/web/docs/common/filters/eq.mdx b/web/docs/common/filters/eq.mdxnew file mode 100644index 00000000000..695596c7e2d--- /dev/null+++ b/web/docs/common/filters/eq.mdx@@ -0,0 +1,29 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .eq(columnName, filterValue)+```++Finds all rows whose value on the stated columnName exactly matches the specified filterValue. Equivalent of `filter(columName, 'eq', criteria)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .eq('name', 'New Zealand')+```++</Collapsable>++#### `columnName: string`+Name of the database column.++#### `filterValue: { string | integer | boolean }`+Value to match.++---\ No newline at end of filediff --git a/web/docs/common/filters/filter.mdx b/web/docs/common/filters/filter.mdxnew file mode 100644index 00000000000..0d798d4ef06--- /dev/null+++ b/web/docs/common/filters/filter.mdx@@ -0,0 +1,34 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .filter(columnName, operator, criteria)+```++All in one convenience function for all filters available.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3-5}+supabase+ .from('countries')+ .filter('name', 'in', '['China', 'France']')+ .filter('name', 'like', '%n%')+ .filter('id', 'gte', 20)+```++</Collapsable>++#### `columnName: string`+Name of the database column.++#### `operator: string`+Name of filter operator to be utilised.++#### `criteria: { object | array | string | integer | boolean | null }`+Value to compare to. Exact data type of criteria would depend on the operator used.++---\ No newline at end of filediff --git a/web/docs/common/filters/gt.mdx b/web/docs/common/filters/gt.mdxnew file mode 100644index 00000000000..8d3ec19950c--- /dev/null+++ b/web/docs/common/filters/gt.mdx@@ -0,0 +1,28 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .gt(columnName, filterValue)+```+Finds all rows whose value on the stated columnName is greater than the specified filterValue. Eqiuvalent of `filter(columnName, 'gt', criteria)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .gt('id', 20)+```++</Collapsable>++#### `columnName: string`+Name of database column.++#### `filterValue: { string | integer | boolean }`+Value to compare to.++---\ No newline at end of filediff --git a/web/docs/common/filters/gte.mdx b/web/docs/common/filters/gte.mdxnew file mode 100644index 00000000000..4e9e237bc79--- /dev/null+++ b/web/docs/common/filters/gte.mdx@@ -0,0 +1,28 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .gte(columnName, filterValue)+```+Finds all rows whose value on the stated columnName is greater than or equal to the specified filterValue. Eqiuvalent of `filter(columnName, 'gte', criteria)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .gte('id', 20)+```++</Collapsable>++#### `columnName: string`+Name of database column.++#### `filterValue: { string | integer | boolean }`+Value to compare to.++---\ No newline at end of filediff --git a/web/docs/common/filters/ilike.mdx b/web/docs/common/filters/ilike.mdxnew file mode 100644index 00000000000..b8a53782361--- /dev/null+++ b/web/docs/common/filters/ilike.mdx@@ -0,0 +1,30 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .ilike(columnName, stringPattern)+```++A case-sensitive version of `like()`. Equivalent of `filter(columnName, 'ilike', stringPattern)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .ilike('name', '%united%')+```++</Collapsable>+++#### `columnName: string`+Name of database column.++#### `stringPattern: string`+String pattern to compare to. A comprehensive guide on how to form proper patterns can be found [here](https://www.postgresql.org/docs/current/functions-matching.html).++---\ No newline at end of filediff --git a/web/docs/common/filters/in.mdx b/web/docs/common/filters/in.mdxnew file mode 100644index 00000000000..15791d74b59--- /dev/null+++ b/web/docs/common/filters/in.mdx@@ -0,0 +1,29 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .in(columnName, filterArray)+```++Finds all rows whose value on the stated columnName is found on the specified filterArray. Equivalent of `filter(columnName, 'in', criteria)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .in('name', ['China', 'France'])+```++</Collapsable>++#### `columnName: string`+Name of database column.++#### `filterArray: array`+Array of values to find a match. Data type of values is dependent on the columnName specified.++---\ No newline at end of filediff --git a/web/docs/common/filters/is.mdx b/web/docs/common/filters/is.mdxnew file mode 100644index 00000000000..9aebdf18934--- /dev/null+++ b/web/docs/common/filters/is.mdx@@ -0,0 +1,31 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .is(columnName, filterValue)+```++A check for exact equality (**null**, **true**, **false**), finds all rows whose value on the state columnName exactly match the specified filterValue.+Equivalent of `filter(columnName, 'is', filterValue)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .is('name', null)+```++</Collapsable>+++#### `columnName: string`+Name of database column.++#### `filterValue: { null | boolean }`+Value to match.++---\ No newline at end of filediff --git a/web/docs/common/filters/like.mdx b/web/docs/common/filters/like.mdxnew file mode 100644index 00000000000..197edd22e3e--- /dev/null+++ b/web/docs/common/filters/like.mdx@@ -0,0 +1,30 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .like(columnName, stringPattern)+```++Finds all rows whose value in the stated columnName matches the supplied pattern. Equivalent of `filter(columnName, 'like', stringPattern)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .like('name', '%United%')+```++</Collapsable>+++#### `columnName: string`+Name of database column.++#### `stringPattern: string`+String pattern to compare to. A comprehensive guide on how to form proper patterns can be found [here](https://www.postgresql.org/docs/current/functions-matching.html).++---\ No newline at end of filediff --git a/web/docs/common/filters/lt.mdx b/web/docs/common/filters/lt.mdxnew file mode 100644index 00000000000..437984b372a--- /dev/null+++ b/web/docs/common/filters/lt.mdx@@ -0,0 +1,28 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .lt(columnName, filterValue)+```+Finds all rows whose value on the stated columnName is less than the specified filterValue. Eqiuvalent of `filter(columnName, 'lt', criteria)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .lt('id', 20)+```++</Collapsable>++#### `columnName: string`+Name of database column.++#### `filterValue: { string | integer | boolean }`+Value to compare to.++---\ No newline at end of filediff --git a/web/docs/common/filters/lte.mdx b/web/docs/common/filters/lte.mdxnew file mode 100644index 00000000000..6477ac050be--- /dev/null+++ b/web/docs/common/filters/lte.mdx@@ -0,0 +1,28 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .lte(columnName, filterValue)+```+Finds all rows whose value on the stated columnName is less than or equal to the specified filterValue. Eqiuvalent of `filter(columnName, 'lte', criteria)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .lte('id', 20)+```++</Collapsable>++#### `columnName: string`+Name of database column.++#### `filterValue: { string | integer | boolean }`+Value to compare to.++---\ No newline at end of filediff --git a/web/docs/common/filters/match.mdx b/web/docs/common/filters/match.mdxindex 3f1c3705ef9..1f7c030b15f 100644--- a/web/docs/common/filters/match.mdx+++ b/web/docs/common/filters/match.mdx@@ -12,7 +12,7 @@ Finds rows that exactly match the specified filterObject. Equivilent of `filter(<Collapsable title="Toggle Example"><!-- prettier-ignore -->-```js+```js {3}supabase.from('countries').match({ 'continent': 'Asia' })@@ -22,4 +22,6 @@ supabase#### `filterObject: object`-An object of `{ 'columnName': 'criteria' }`\ No newline at end of file+An object of `{ 'columnName': 'criteria' }`++---\ No newline at end of filediff --git a/web/docs/common/filters/not.mdx b/web/docs/common/filters/not.mdxnew file mode 100644index 00000000000..33fcd5044f6--- /dev/null+++ b/web/docs/common/filters/not.mdx@@ -0,0 +1,29 @@+import Collapsable from '../../../src/components/Collapsable'++<!-- prettier-ignore -->+```js {3}+supabase+ .from(tableName)+ .not(columnName, filterValue)+```++Finds all rows whose value on the stated columnName does not match the specified filterValue. Equivalent of `filter(columnName, 'not', criteria)`.++<Collapsable title="Toggle Example">++<!-- prettier-ignore -->+```js {3}+supabase+ .from('countries')+ .not('name', 'China')+```++</Collapsable>++#### `columnName: string`+Name of database column.++#### `filterValue: { string | integer | boolean }`+Value to **not** match.++---\ No newline at end of filediff --git a/web/docs/library/get.mdx b/web/docs/library/get.mdxindex a9dc87a558c..b9de66fa935 100644--- a/web/docs/library/get.mdx+++ b/web/docs/library/get.mdx@@ -6,9 +6,10 @@ title: 'Reading'import Tabs from '@theme/Tabs'import TabItem from '@theme/TabItem'import DummyData from '../common/DummyData.mdx'-import Match from '../common/filters/match.mdx'+// import Index from '../common/filters/Index'+import CommonFilters from '../common/CommonFilters'import CommonResponses from '../common/CommonResponses.mdx'-import CommonFilters from '../common/CommonFilters.mdx'+// import CommonFilters from '../common/CommonFilters.mdx'import Collapsable from '../../src/components/Collapsable'We will be using these tables as reference for our examples:@@ -274,17 +275,49 @@ Returns the first row of the table as an object and **not** as an array.-----### `filter()`-### `match()`-<Match />+## Filtering-<CommonFilters verb="get" />+### `filter()`+<CommonFilters filter='filter'/>++### `match()`+<CommonFilters filter='match'/>++### `eq()`+<CommonFilters filter='eq'/>++### `gt()`+<CommonFilters filter='gt'/>++### `lt()`+<CommonFilters filter='lt'/>++### `gte()`+<CommonFilters filter='gte'/>++### `lte()`+<CommonFilters filter='lte'/>++### `like()`+<CommonFilters filter='like'/>++### `ilike()`+<CommonFilters filter='ilike'/>++### `is()`+<CommonFilters filter='is'/>++### `in()`+<CommonFilters filter='in'/>++### `not()`+<CommonFilters filter='not'/>## Responses