mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Complete Documentation for Update & Delete Rows
The following were done: - Complete delete.mdx and patch.mdx. - (Boyscout) Change one sentence in about.md. - Reroute internal links due to the restructuring of the library section in the previous commit.
This commit is contained in:
1 parent
5f8f3055bd
commit
fda3aa9419
6 files changed
+198
-32
No files matched your search
+1
-1
@@ -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
|
||||
|
||||
|
||||
+82
-12
@@ -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
|
||||
<Tabs
|
||||
defaultValue="nodeJs"
|
||||
values={[
|
||||
{ label: 'Node.js', value: 'nodeJs', },
|
||||
{ label: 'Python', value: 'py', },
|
||||
]
|
||||
}>
|
||||
<TabItem value="nodeJs">
|
||||
|
||||
## Examples
|
||||
```js
|
||||
supabase.delete(tableName, options?)
|
||||
|
||||
@todo various examples
|
||||
```
|
||||
Given the `options?` set (if any), this delete all rows from the specified `tableName`.
|
||||
</TabItem>
|
||||
|
||||
## Options
|
||||
<TabItem value="py">
|
||||
|
||||
| Parameter | Default | Description |
|
||||
| --------- | ------- | ------------------------------------------- |
|
||||
| @todo | | All options |
|
||||
```py
|
||||
# TODO
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## 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).
|
||||
@@ -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
|
||||
|
||||
@@ -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).
|
||||
Aside from the status code `200 OK`, other common responses can be found [here](../library/responses).
|
||||
+108
-12
@@ -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
|
||||
<Tabs
|
||||
defaultValue="nodeJs"
|
||||
values={[
|
||||
{ label: 'Node.js', value: 'nodeJs', },
|
||||
{ label: 'Python', value: 'py', },
|
||||
]
|
||||
}>
|
||||
<TabItem value="nodeJs">
|
||||
|
||||
## 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`.
|
||||
</TabItem>
|
||||
|
||||
## Options
|
||||
<TabItem value="py">
|
||||
|
||||
| Parameter | Default | Description |
|
||||
| --------- | ------- | ------------------------------------------- |
|
||||
| @todo | | All options |
|
||||
```py
|
||||
# TODO
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Returns
|
||||
<Tabs
|
||||
defaultValue="nodeJs"
|
||||
values={[
|
||||
{ label: 'Node.js', value: 'nodeJs', },
|
||||
{ label: 'Python', value: 'py', },
|
||||
]
|
||||
}>
|
||||
<TabItem value="nodeJs">
|
||||
|
||||
#### 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`.
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="py">
|
||||
|
||||
```py
|
||||
# TODO
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## 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).
|
||||
@@ -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).
|
||||
Other responses can be found [here](../library/responses).
|
||||
Reference in new issue
Block a user