mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Delete examples for #21
This commit is contained in:
1 parent
63038efe7a
commit
b68685403c
2 files changed
+413
-5
No files matched your search
+195
-3
@@ -10,7 +10,20 @@ import CommonResponses from '../common/CommonResponses.mdx'
|
||||
import CommonFilters from '../common/CommonFilters'
|
||||
import FromFunction from '../common/FromFunction.mdx'
|
||||
import CustomCodeBlock from '../../src/components/CustomCodeBlock'
|
||||
import { deleteRecordJs } from './examples/delete'
|
||||
import { deleteRecordJs,
|
||||
deleteFilterJs,
|
||||
deleteMatchJs,
|
||||
deleteEqJs,
|
||||
deleteGtJs,
|
||||
deleteLtJs,
|
||||
deleteGteJs,
|
||||
deleteLteJs,
|
||||
deleteLikeJs,
|
||||
deleteIlikeJs,
|
||||
deleteIsJs,
|
||||
deleteInJs,
|
||||
deleteNotJs
|
||||
} from './examples/delete'
|
||||
|
||||
|
||||
<DummyData />
|
||||
@@ -56,48 +69,227 @@ const options = {
|
||||
|
||||
----
|
||||
|
||||
|
||||
## Filtering
|
||||
|
||||
### `filter()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use filter( ) with delete( )"
|
||||
js={deleteFilterJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='filter'/>
|
||||
|
||||
### `match()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use match( ) with delete( )"
|
||||
js={deleteMatchJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='match'/>
|
||||
|
||||
### `eq()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use eq( ) with delete( )"
|
||||
js={deleteEqJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='eq'/>
|
||||
|
||||
### `gt()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use gt( ) with delete( )"
|
||||
js={deleteGtJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='gt'/>
|
||||
|
||||
### `lt()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use lt( ) with delete( )"
|
||||
js={deleteLtJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='lt'/>
|
||||
|
||||
### `gte()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use gte( ) with delete( )"
|
||||
js={deleteGteJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='gte'/>
|
||||
|
||||
### `lte()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use lte( ) with delete( )"
|
||||
js={deleteLteJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='lte'/>
|
||||
|
||||
### `like()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use like( ) with delete( )"
|
||||
js={deleteLikeJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='like'/>
|
||||
|
||||
### `ilike()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use ilike( ) with delete( )"
|
||||
js={deleteIlikeJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='ilike'/>
|
||||
|
||||
### `is()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use is( ) with delete( )"
|
||||
js={deleteIsJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='is'/>
|
||||
|
||||
### `in()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use in( ) with delete( )"
|
||||
js={deleteInJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='in'/>
|
||||
|
||||
### `not()`
|
||||
|
||||
<CustomCodeBlock
|
||||
header="Shows how to use not( ) with delete( )"
|
||||
js={deleteNotJs}
|
||||
jsHighlight="{9}"
|
||||
response={`{
|
||||
"body": null,
|
||||
"status": 204,
|
||||
"statusCode": 204,
|
||||
"statusText": "No Content"
|
||||
}`}
|
||||
/>
|
||||
|
||||
<br/>
|
||||
|
||||
<CommonFilters filter='not'/>
|
||||
|
||||
## Responses
|
||||
|
||||
#### 200 OK
|
||||
Successful
|
||||
Successful request
|
||||
|
||||
<CommonResponses />
|
||||
@@ -7,7 +7,7 @@ import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
|
||||
|
||||
const updateCountryName = async () => {
|
||||
const deleteCity = async () => {
|
||||
try {
|
||||
let values = await supabase
|
||||
.from('cities')
|
||||
@@ -19,4 +19,220 @@ const updateCountryName = async () => {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
`
|
||||
|
||||
export const deleteFilterJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.filter({'name', 'eq', 'Paris'})
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteMatchJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.match({name: 'Beijing', country_id: 156})
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteEqJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.eq('name', 'San Francisco')
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteGtJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.gt('country_id', 250)
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteLtJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.lt('country_id', 250)
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteGteJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.gte('country_id', 250)
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteLteJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.lte('country_id', 250)
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteLikeJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.like('name', '%la%')
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteIlikeJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.ilike('name', '%la%')
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteIsJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.is('name', null)
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteInJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.in('name', ['Rio de Janeiro', 'San Francisco'])
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const deleteNotJs = `
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const supabase = createClient('https://world.supabase.co', 'public-key-bOYapLADERfE')
|
||||
|
||||
const deleteCIty = async () => {
|
||||
try {
|
||||
let cities = await supabase
|
||||
.from('cities')
|
||||
.not('name', 'Lagos')
|
||||
.delete()
|
||||
return cities
|
||||
} catch (error) {
|
||||
console.log('Error: ', error)
|
||||
}
|
||||
}
|
||||
`
|
||||
Reference in new issue
Block a user