diff --git a/web/docs/about.md b/web/docs/about.md index 5499ec0cba5..89dadac5f64 100755 --- a/web/docs/about.md +++ b/web/docs/about.md @@ -30,7 +30,7 @@ For all Restful functionality, we introspect your database to provide an out-of- - Fast. Performance and simplicity are our two most important features. - 100% open source under the Apache 2.0 License. - Accessible by mobile and web with simple client libraries. -- Works without any major changes to your database (like adding `NOTIFY` functions) or additional plugins (like `wal2json`). By using PostgreSQL's replication functionality we overcome many their limitations. For example, `NOTIFY` has a 8000 byte payload limit, making it hard to listen to bulk changes. +- Works without any major changes to your database (like adding `NOTIFY` functions) or additional plugins (like `wal2json`). By using PostgreSQL's replication functionality we overcome many of their limitations. For example, `NOTIFY` has a 8000 byte payload limit, making it hard to listen to bulk changes. ## Benefits diff --git a/web/docs/library/delete.mdx b/web/docs/library/delete.mdx index 32448c0f458..d5ab1e64a18 100644 --- a/web/docs/library/delete.mdx +++ b/web/docs/library/delete.mdx @@ -3,24 +3,94 @@ id: delete title: 'Delete Rows' --- -@todo short Description +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; -## The basics +We will be using these tables as reference for our examples: +```json +{ + "companies": [ + { "Id": 1, "name": "Pied Piper", "employeeCount": 10 }, + { "Id": 2, "name": "Hooli", "employeeCount": 1000 }, + { "Id": 3, "name": "Yao Net", "employeeCount": 100 }, + { "Id": 4, "name": "See Food App", "employeeCount": null } + ], +} +``` -@todo most simple usage + + -## Examples +```js +supabase.delete(tableName, options?) -@todo various examples +``` +Given the `options?` set (if any), this delete all rows from the specified `tableName`. + -## Options + -| Parameter | Default | Description | -| --------- | ------- | ------------------------------------------- | -| @todo | | All options | +```py +# TODO +``` + + -## Returns +## Method arguments +### tableName +`required` string +Name of table in the database that will have its rows deleted. -#### 200: Success +### options +`optional` object +All available options and examples it their usage can be found [here](../library/options). -@todo: all return scenarios +## Additional filtering +To specifically indicate which resources are to be deleted, additional filters can be used. +They can be found [here](../library/filters). + +## Example + +### Mass delete +Updating employeeCount for all companies. +```js +supabase.delete("companies") +``` + +Upon a successful deletion, the status code `204 Accepted` will be returned. + +```js +supabase.get("companies") +``` +When getting all companies again, as shown above, the following will be returned with the status code `200 OK`: +```json +[] +``` + +### Using filters +Deleting companies where its columnName "name" is equal to "See Food App". +```js +supabase.delete("companies").eq("name", "See Food App") +``` + +Upon a successful deletion, the status code `204 Accepted` will be returned. +```js +supabase.get("companies") +``` +When getting all companies again, as shown above, the following will be returned with the status code `200 OK`: +```json +[ + { "Id": 1, "name": "Pied Piper", "employeeCount": 10 }, + { "Id": 2, "name": "Hooli", "employeeCount": 1000 }, + { "Id": 3, "name": "Yao Net", "employeeCount": 100 } +] +``` + +## Responses +Aside from the status code `204 Accepted`, other common responses can be found [here](../library/responses). \ No newline at end of file diff --git a/web/docs/library/filters.mdx b/web/docs/library/filters.mdx index c09995784b4..c4125e33701 100644 --- a/web/docs/library/filters.mdx +++ b/web/docs/library/filters.mdx @@ -343,7 +343,7 @@ The following will be returned with status code `200 OK`: ilike(columnName, filterValue) ``` -A case-insensitive version of [like(columnName, filterValue)](../restful/filters#like). +A case-insensitive version of [like(columnName, filterValue)](../library/filters#like). ### Method arguments #### columnName diff --git a/web/docs/library/get.mdx b/web/docs/library/get.mdx index 8b0da5f038b..b755beb686d 100644 --- a/web/docs/library/get.mdx +++ b/web/docs/library/get.mdx @@ -53,7 +53,7 @@ Name of table in the database that will be read from. ### options `optional` object -All available options and examples it their usage can be found [here](../restful/options). +All available options and examples it their usage can be found [here](../library/options). ## Additional filtering ### Select @@ -91,11 +91,11 @@ Instead of stating the column name with the foreign key constraint, the name of along with the desired column names from that table. ##### Example -Click [here](../restful/get#using-select) view some examples. +Click [here](../library/get#using-select) view some examples. ### Common Filters -Other common filters can be found [here](../restful/filters). +Other common filters can be found [here](../library/filters). ## Example @@ -161,4 +161,4 @@ The following will be returned with the status code `200 OK`: ``` ## Responses -Aside from the status code `200 OK`, other common responses can be found [here](../restful/responses). \ No newline at end of file +Aside from the status code `200 OK`, other common responses can be found [here](../library/responses). \ No newline at end of file diff --git a/web/docs/library/patch.mdx b/web/docs/library/patch.mdx index 27f2e560641..528447cd24f 100644 --- a/web/docs/library/patch.mdx +++ b/web/docs/library/patch.mdx @@ -3,24 +3,120 @@ id: patch title: 'Update Rows' --- -@todo short Description +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; -## The basics +We will be using these tables as reference for our examples: +```json +{ + "companies": [ + { "Id": 1, "name": "Pied Piper", "employeeCount": 10 }, + { "Id": 2, "name": "Hooli", "employeeCount": 1000 }, + { "Id": 3, "name": "Yao Net", "employeeCount": 100 }, + { "Id": 4, "name": "See Food App", "employeeCount": null } + ], +} +``` -@todo most simple usage + + -## Examples +```js +supabase.patch(tableName, data, options?) -@todo various examples +``` +Given the `options?` set (if any), this **asynchronously** and partially updates all rows from the specified `tableName` in your database +with the specified `data`. + -## Options + -| Parameter | Default | Description | -| --------- | ------- | ------------------------------------------- | -| @todo | | All options | +```py +# TODO +``` + + -## Returns + + -#### 200: Success +```js +supabase.put(tableName, data, options?) -@todo: all return scenarios +``` +Given the `options?` set (if any), this **asynchronously** and fully replaces all rows from the specified `tableName` in your database +with the specified `data`. + + + + +```py +# TODO +``` + + + +## Method arguments +Arguments for both types of update are the same. +### tableName +`required` string +Name of table in the database that will be updated. + +### data +`required` array +Array of rows of type `object` which contain information to be updated into the selected table. + + +### options +`optional` object +All available options and examples it their usage can be found [here](../library/options). + +## Additional filtering +To specifically indicate which resources are to be updated, additional filters can be used. +They can be found [here](../library/filters). + +## Example + +### Mass update +Updating employeeCount for all companies. +```js +supabase.patch("companies", { employeeCount: 50 }) +``` + +The following will be returned with the status code `200 OK`: +```json +[ + { "Id": 1, "name": "Pied Piper", "employeeCount": 50 }, + { "Id": 2, "name": "Hooli", "employeeCount": 50 }, + { "Id": 3, "name": "Yao Net", "employeeCount": 50 }, + { "Id": 4, "name": "See Food App", "employeeCount": 50 } +] +``` + +### Using filters +Updating employeeCount for companies where its columnName "name" is equal to "See Food App". +```js +supabase.patch("companies", { employeeCount: 50 }).eq("name", "See Food App") +``` + +The following will be returned with the status code `200 OK`: +```json +[ + { "Id": 4, "name": "See Food App", "employeeCount": 50 } +] +``` + +## Responses +Aside from the status code `200 OK`, other common responses can be found [here](../library/responses). \ No newline at end of file diff --git a/web/docs/library/post.mdx b/web/docs/library/post.mdx index 787df6fc697..59a5aba3af4 100644 --- a/web/docs/library/post.mdx +++ b/web/docs/library/post.mdx @@ -42,7 +42,7 @@ Array of rows of type `object` which contain information to be saved into the se ### options `optional` object -All available options and examples it their usage can be found [here](../restful/options). +All available options and examples it their usage can be found [here](../library/options). ## Example @@ -136,4 +136,4 @@ The request has succeeded. New resource created will be returned: ``` ### Common Responses -Other responses can be found [here](../restful/responses). \ No newline at end of file +Other responses can be found [here](../library/responses). \ No newline at end of file