Files
supabase/web/docs/library/patch.mdx
T

80 lines
1.2 KiB
Plaintext

---
id: patch
title: 'Updating your data'
---
import DummyData from '../common/DummyData.mdx'
import Collapsable from '../../src/components/Collapsable'
import CommonResponses from '../common/CommonResponses.mdx'
import CommonFilters from '../common/CommonFilters.mdx'
We will be using these tables as reference for our examples:
<DummyData />
### Update record
This example how to update a country:
<!-- prettier-ignore -->
```js {8}
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('https://world.supabase.io', '1a2b-3c4d-5e6f-7g8h')
const updateCountryName = async () => {
try {
let updates = await supabase
.patch('countries', { name: 'Middle Earth' })
.match({ name: 'New Zealand' })
return updates
} catch (error) {
console.log('Error: ', error)
}
}
```
<Collapsable title="Toggle Example Response">
@todo
</Collapsable>
## Reference
### `patch()`
```js
supabase
.patch(tableName, data, options?)
```
##### tableName `:string`
Name of table in the database where data will be saved.
##### data `:object`
New record values.
##### options `:object?`
@todo
----
## Filtering
<CommonFilters verb="patch" />
## Responses
#### 200 OK
Successful
<CommonResponses />