The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Write Documentation for Generic RESTful Features
Angelicob3b34c15fc58
diff --git a/web/docs/library/getting-started.mdx b/web/docs/library/getting-started.mdxindex 50750768723..601ca391ac1 100755--- a/web/docs/library/getting-started.mdx+++ b/web/docs/library/getting-started.mdx@@ -42,14 +42,14 @@ from supabase import createClient<TabItem value="nodeJs">```js-const base = createClient("https://xyzcompany.supabase.io", "1a2b-3c4d-5e6f-7g8h");+const supabase = createClient("https://xyzcompany.supabase.io", "1a2b-3c4d-5e6f-7g8h");```</TabItem><TabItem value="py">```py-base = createClient("https://xyzcompany.supabase.io", "1a2b-3c4d-5e6f-7g8h")+supabase = createClient("https://xyzcompany.supabase.io", "1a2b-3c4d-5e6f-7g8h")```</TabItem></Tabs>diff --git a/web/docs/library/restful/filters.mdx b/web/docs/library/restful/filters.mdxnew file mode 100644index 00000000000..db263420a16--- /dev/null+++ b/web/docs/library/restful/filters.mdx@@ -0,0 +1,472 @@+---+id: filters+title: 'Query Filters'+---++import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++We will be using this table as reference for our examples:+```json+{+ "companies":[+ { "name": "Pied Piper", "employeeCount": 10 },+ { "name": "Hooli", "employeeCount": 1000 },+ { "name": "Yao Net", "employeeCount": 100 },+ { "name": "See Food App", "employeeCount": null }+ ]+}+```+## Order+```js+order(columnName, ascending=false, nullsFirst=false)+```++Returns an ordered array of rows based on stated preferences.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the order on.++#### ascending+`optional` boolean+Determines whether the order will be ascending or descending. Default value will be **false**.++#### nullsFirst+`optional` boolean+Determines whether null values will be displayed first or not. Default value will be **false**.++### Example+```js+supabase.get("companies").order("employeeCount", true, true)+```+The following will be returned:+```json+[+ { "name": "See Food App", "employeeCount": null },+ { "name": "Pied Piper", "employeeCount": 10 },+ { "name": "Yao Net", "employeeCount": 100 },+ { "name": "Hooli", "employeeCount": 1000 }+]+```++---++## Range+```js+range(from, to?)+```++Returns an array of rows based on specified range and position of rows with regards to the table.++### Method arguments+#### from+`required` integer+Index or position of the start of the specified range.+++#### to+`optional` integer+Index or position of the end of the specified range. If not stated, all remaining rows after the starting index will be returned.++### Example+#### With both `from` and `to` specified+```js+supabase.get("companies").range(0,2)+```+The following will be returned:+```json+[+ { "name": "Pied Piper", "employeeCount": 10 },+ { "name": "Hooli", "employeeCount": 1000 },+ { "name": "Yao Net", "employeeCount": 100 }+]++```++#### With `from` only specified+```js+supabase.get("companies").range(1)+```+The following will be returned:+```json+[+ { "name": "Yao Net", "employeeCount": 100 },+ { "name": "See Food App", "employeeCount": null }+]++```++---++## Single+```js+single()+```+Returns the first row of the table as an object and **not** as an array.++### Example+```js+supabase.get("companies").single()+```+The following will be returned:+```json+{ "name": "Pied Piper", "employeeCount": 10 }+```+---++## Match+```js+match(filterObject)+```++Returns an array of rows that exactly match the specified filterObject.++### Method arguments+#### filterObject+`required` object+Object contains column names and the desired values.++### Example+#### Generic+```js+supabase.get("companies").match({ "name": "Pied Piper", "employeeCount": 10 })+```+The following will be returned:+```json+[+ { "name": "Pied Piper", "employeeCount": 10 }+]+```++#### No matches+```js+supabase.get("companies").match({ "name": "Pied Piper", "employeeCount": 50 })+```+The following will be returned:+```json+[]+```++---++# Advanced Filtering++## Equals+```js+eq(columnName, filterValue)+```+Returns an array of rows whose value on the stated columnName exactly matches the specified filterValue.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the match on.++#### filterValue+`required`+Value to match. Data type is dependent on the columnName specified.++### Example+```js+supabase.get("companies").eq("name", "Hooli")+```++The following will be returned:+```json+[+ { "name": "Hooli", "employeeCount": 1000 }+]+```++---++## Greater Than+```js+gt(columnName, filterValue)+```++Returns an array of rows whose value on the stated columName is greater than the specified filterValue.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the comparison on.++#### filterValue+`required`+Value to compare to. Data type is dependent on the columnName specified.++### Example+```js+supabase.get("companies").gt("employeeCount", 10)+```++The following will be returned:+```json+[+ { "name": "Hooli", "employeeCount": 1000 },+ { "name": "Yao Net", "employeeCount": 100 }+]+```++---++## Less Than+```js+lt(columnName, filterValue)+```++Returns an array of rows whose value on the stated columnName is less than the specified filterValue.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the comparison on.++#### filterValue+`required`+Value to compare to. Data type is dependent on the columnName specified.++### Example+```js+supabase.get("companies").lt("employeeCount", "1000")+```++The following will be returned:+```json+[+ { "name": "Pied Piper", "employeeCount": 10 },+ { "name": "Yao Net", "employeeCount": 100 }+]+```++---++## Greater Than or Equal+```js+gte(columnName, filterValue)+```++Returns an array of rows whose value on the stated columName is greater than or equal to the specified filterValue.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the comparison on.++#### filterValue+`required`+Value to compare to. Data type is dependent on the columnName specified.++### Example+```js+supabase.get("companies").gte("employeeCount", 10)+```++The following will be returned:+```json+[+ { "name": "Pied Piper", "employeeCount": 10 },+ { "name": "Hooli", "employeeCount": 1000 },+ { "name": "Yao Net", "employeeCount": 100 }+]+```++---++## Less Than or Equal+```js+lte(columnName, filterValue)+```++Returns an array of rows whose value on the stated columnName is less than or equal to the specified filterValue.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the comparison on.++#### filterValue+`required`+Value to compare to. Data type is dependent on the columnName specified.++### Example+```js+supabase.get("companies").lte("employeeCount", "1000")+```++The following will be returned:+```json+[+ { "name": "Pied Piper", "employeeCount": 10 },+ { "name": "Hooli", "employeeCount": 1000 },+ { "name": "Yao Net", "employeeCount": 100 }+]+```++---++## Like+```js+like(columnName, stringPattern)+```++Returns an array of rows whose value in the stated columnName matches the supplied pattern.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the comparison on.++#### stringPattern+`required` 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).++### Example+```js+supabase.get("companies").like("name", "%ao%")+```++The following will be returned:+```json+[+ { "name": "Yao Net", "employeeCount": 100 }+]+```++---++## Ilike+```js+ilike(columnName, filterValue)+```++A case-insensitive version of [like(columnName, filterValue)](../restful/filters#like).++### Method arguments+#### columnName+`required` string+Name of chosen column to base the match on.++#### stringPattern+`required` string+String pattern to compare to. A comprehensive guide on how to form patterns can be found [here](https://www.postgresql.org/docs/current/functions-matching.html).++### Example+#### Using like+```js+supabase.get("companies").like("name", "_pi%")+```++The following will be returned:+```json+[]+```++#### Using ilike+```js+supabase.get("companies").ilike("name", "_pi%")+```++The following will be returned:+```json+[+ { "name": "Pied Piper", "employeeCount": 10}+]+```++---++## Is+```js+is(columnName, filterValue)+```++A check for exact equality (**null**, **true**, **false**), returns an array of rows whose value on the stated columnName exactly match the specified filterValue.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the match on.++#### filterValue+`required` boolean **OR** null+Value to match.++### Example+```js+supabase.get("companies").is("employeeCount", null)+```++The following will be returned:+```json+[+ { "name": "See Food App", "employeeCount": null }+]+```++---++## In+```js+in(columnName, filterArray)+```++Returns an array of rows whose value on the stated columnName is found on the specified filterArray.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the match on.++#### filterArray+`required` array+Array of values to find a match. Data type of values is dependent on the columnName specified.++### Example+```js+supabase.get("companies").in("name", ["Hooli", "Pied Piper", "Google"])+```++The following will be returned:+```json+[+ { "name": "Pied Piper", "employeeCount": 10 },+ { "name": "Hooli", "employeeCount": 1000 }+]+```++---++## Not+```js+not(columnName, filterValue)+```++Returns of array of rows whose value on the stated columnName is **not** equal to the specified value.++### Method arguments+#### columnName+`required` string+Name of chosen column to base the match on.++#### filterValue+`required`+Value to **not** match. Data type is dependent on the columnName specified.++### Example+```js+supabase.get("companies").not("name", "See Food App")+```++The following will be returned:+```json+[+ { "name": "Pied Piper", "employeeCount": 10 },+ { "name": "Hooli", "employeeCount": 1000 },+ { "name": "Yao Net", "employeeCount": 100 }+]+```+diff --git a/web/docs/library/restful/options.mdx b/web/docs/library/restful/options.mdxnew file mode 100644index 00000000000..93e40fb4f3e--- /dev/null+++ b/web/docs/library/restful/options.mdx@@ -0,0 +1,146 @@+---+id: options+title: 'Available Options'+---++import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++A list of all available options that can be specified under the `options?` parameter.++## headers+`optional` object+Custom headers to be sent. A complete list of headers can be found [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers).++### Example+<Tabs+ defaultValue="nodeJs"+ values={[+ { label: 'Node.js', value: 'nodeJs', },+ { label: 'Python', value: 'py', },+ ]+}>+<TabItem value="nodeJs">++```js {9-14}+const postUsers = async () => {+ try {+ let users = await supabase+ .post(+ "users",+ [+ { name: "Nelson Bighetti" },+ ],+ {+ headers:{+ "Content-Type": "application/x-www-form-urlencoded"+ "X-requested-With": "XMLHttpRequest"+ }+ }+ )+ return users+ } catch (error) {+ console.log('Error:', error)+ }+}++```+</TabItem>++<TabItem value="py">++```py+# TODO+```+</TabItem>+</Tabs>++---++## withCredentials+`optional` boolean+Determines the ability to send cookies from origin.++### Example+Setting withCredentials with value **true** allows the request to send cookies from origin+<Tabs+ defaultValue="nodeJs"+ values={[+ { label: 'Node.js', value: 'nodeJs', },+ { label: 'Python', value: 'py', },+ ]+}>+<TabItem value="nodeJs">++```js {9}+const postUsers = async () => {+ try {+ let users = await supabase+ .post(+ "users",+ [+ { name: "Nelson Bighetti" },+ ],+ { withCredentials: true }+ )+ return users+ } catch (error) {+ console.log('Error:', error)+ }+}++```+</TabItem>++<TabItem value="py">++```py+# TODO+```+</TabItem>+</Tabs>++---++## timeout+`optional` integer+Specifies the amount of time in milliseconds before the request times out.++### Example+Setting a timeout of value 5000 will cause the request to time out after 5000 milliseconds.+<Tabs+ defaultValue="nodeJs"+ values={[+ { label: 'Node.js', value: 'nodeJs', },+ { label: 'Python', value: 'py', },+ ]+}>+<TabItem value="nodeJs">++```js {9}+const postUsers = async () => {+ try {+ let users = await supabase+ .post(+ "users",+ [+ { name: "Nelson Bighetti" },+ ],+ { timeout: 5000 }+ )+ return users+ } catch (error) {+ console.log('Error:', error)+ }+}++```+</TabItem>++<TabItem value="py">++```py+# TODO+```+</TabItem>+</Tabs>\ No newline at end of filediff --git a/web/docs/library/restful/post.mdx b/web/docs/library/restful/post.mdxindex 181e2261658..62f2d8f7a5e 100644--- a/web/docs/library/restful/post.mdx+++ b/web/docs/library/restful/post.mdx@@ -3,7 +3,6 @@ id: posttitle: 'Create Rows'----import Tabs from '@theme/Tabs';import TabItem from '@theme/TabItem';@@ -17,23 +16,10 @@ import TabItem from '@theme/TabItem';<TabItem value="nodeJs">```js-const fetchUsers = async () => {- try {- let users = await base- .post(- "users",- [- { name: "Richard Hendrix" },- { name: "Elrich Bachman" }- ],- )- return users- } catch (error) {- console.log('Error:', error)- }-}+supabase.post(tableName, data, options?)```+Given the `options?` set, this posts `data` into the selected `tableName` in your database.</TabItem><TabItem value="py">@@ -44,46 +30,60 @@ const fetchUsers = async () => {</TabItem></Tabs>-## createClient.post(tableName, data, options?)-Given the `options?` set, this posts `data` into the selected `tableName` in your database.-## Method arguments-#### tableName+### tableName`required` stringName of table in the database where data will be saved.-#### data+### data`required` arrayArray of rows of type `object` which contain information to be saved into the selected table.-#### options-`optional` object-- headers+### options`optional` object-Custom headers to be sent. A complete list of headers can be found [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers).+All available options and examples it their usage can be found [here](../restful/options).-- withCredentials-`optional` boolean-Determines the ability to send cookies from the origin.+## Example-- timeout-`optional` integer-Specifies the amount of time in milliseconds before the request times out.+### Posting a Single Row+<Tabs+ defaultValue="nodeJs"+ values={[+ { label: 'Node.js', value: 'nodeJs', },+ { label: 'Python', value: 'py', },+ ]+}>+<TabItem value="nodeJs">-- auth-`optional` object-Allows authentications through given credentials.+```js {6-8}+const postUsers = async () => {+ try {+ let users = await supabase+ .post(+ "users",+ [+ { name: "Nelson Bighetti" },+ ],+ )+ return users+ } catch (error) {+ console.log('Error:', error)+ }+}-| Parameter | Required | Data Type | Description |-| ---------- | ---------- | --------- | ----------- |-| username | `required` | string | Username |-| password | `required` | string | Password |+```+</TabItem>+<TabItem value="py">-## Example+```py+# TODO+```+</TabItem>+</Tabs>-### With all options specified+### Posting Multiple Rows<TabsdefaultValue="nodeJs"values={[@@ -93,27 +93,16 @@ Allows authentications through given credentials.}><TabItem value="nodeJs">-```js-const fetchUsers = async () => {+```js {6-9}+const postUsers = async () => {try {- let users = await base+ let users = await supabase.post("users",[{ name: "Richard Hendrix" },{ name: "Elrich Bachman" }],- {- headers:{-- },- withCredentials: true,- timeout: 1000,- auth:{- username: "password"- password: "password"- }- })return users} catch (error) {@@ -132,9 +121,7 @@ const fetchUsers = async () => {</TabItem></Tabs>-## Responses-### 201 CreatedThe request has succeeded. New resource created will be returned:@@ -148,15 +135,5 @@ The request has succeeded. New resource created will be returned:```-### 400 Bad request-An invalid syntax or configuration was sent.--### 401 Unauthorized-Either authentication is required or invalid credentials were provided under the `auth` object.--### 404 Not found-Requested resource cannot be found.--### 500 Internal Server Error-The server was unable to encounter the situation it encountered.-+### Common Responses+Other responses can be found [here](../restful/responses).\ No newline at end of filediff --git a/web/docs/library/restful/responses.mdx b/web/docs/library/restful/responses.mdxnew file mode 100644index 00000000000..59982ccc94b--- /dev/null+++ b/web/docs/library/restful/responses.mdx@@ -0,0 +1,16 @@+---+id: responses+title: 'Common Responses'+---++## 400 Bad request+An invalid syntax or configuration was sent.++<!-- ## 401 Unauthorized+Either authentication is required or invalid credentials were provided under the [`auth` object](https://google.com). -->++## 404 Not found+Requested resource cannot be found.++## 500 Internal Server Error+The server was unable to encounter the situation it encountered.diff --git a/web/sidebars.js b/web/sidebars.jsindex eddbc82be64..99e13aac292 100755--- a/web/sidebars.js+++ b/web/sidebars.js@@ -27,7 +27,10 @@ module.exports = {"library/restful/post","library/restful/get","library/restful/patch",- "library/restful/delete"+ "library/restful/delete",+ "library/restful/filters",+ "library/restful/options",+ "library/restful/responses"]}],