Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Update Documentation

Angelico293587272da6
diff --git a/web/docs/library/delete.mdx b/web/docs/library/delete.mdx
index 0ab4aa5ed8d..b5e96bf730b 100644
--- a/web/docs/library/delete.mdx
+++ b/web/docs/library/delete.mdx
@@ -9,6 +9,8 @@ import Collapsable from '../../src/components/Collapsable'
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 './getExamples'
<DummyData />
@@ -16,34 +18,17 @@ import FromFunction from '../common/FromFunction.mdx'
### Delete records
-This example how to delete a city:
-
-<!-- prettier-ignore -->
-```js {7-10}
-import { createClient } from '@supabase/supabase-js'
-
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-const updateCountryName = async () => {
- try {
- let values = await supabase
- .from('cities')
- .match({ id: 666 })
- .delete()
-
- return values
- } catch (error) {
- console.log('Error: ', error)
- }
-}
-```
-
-<Collapsable title="Toggle Example Response">
-
-@todo
-
-</Collapsable>
-
+<CustomCodeBlock
+ header="Deletes city."
+ js={deleteRecordJs}
+ jsHighlight="{7-10}"
+ response={`{
+ "body": null,
+ "status": 204,
+ "statusCode": 204,
+ "statusText": "No Content"
+}`}
+/>
## Reference
diff --git a/web/docs/library/get.mdx b/web/docs/library/get.mdx
index a962752497c..36f6162ea32 100644
--- a/web/docs/library/get.mdx
+++ b/web/docs/library/get.mdx
@@ -62,57 +62,6 @@ import { getSimpleJs, getColumnsJs, getForeignJs, getForeignMultipleJs } from '.
/>
-### Query foreign tables
-
-<CustomCodeBlock
- header="Shows how to get all countries and the name of each of their cities"
- js={getForeignJs}
- jsHighlight="{9-14}"
- response={`{
- body: [
- {
- "name": "Brazil",
- "cities": [
- { "name": "Rio de Janeiro" }
- ]
- },
- {
- "name": "China",
- "cities": [
- { "name": "Beijing" }
- ]
- },
- {
- "name": "France",
- "cities": [
- { "name": "Paris" }
- ]
- },
- {
- "name": "New Zealand",
- "cities": [
- { "name": "Auckland" }
- ]
- },
- {
- "name": "Nigeria",
- "cities": [
- { "name": "Lagos" }
- ]
- },
- {
- "name": "United States",
- "cities": [
- { "name": "San Francisco" }
- ]
- }
- ],
- status: 200,
- statusCode: 200,
- statusText: "OK"
-}`}
-/>
-
### Query foreign tables
<CustomCodeBlock
diff --git a/web/docs/library/getExamples.js b/web/docs/library/getExamples.js
index bd9278cfae1..81b3cce8ef8 100644
--- a/web/docs/library/getExamples.js
+++ b/web/docs/library/getExamples.js
@@ -1,3 +1,135 @@
+/**
+ * subscribe.mdx examples
+ */
+
+export const subscribeAllJs = `
+import { createClient } from '@supabase/supabase-js'
+
+// Create a single supabase client for interacting with your database
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+// Listen to changes
+const mySubscription = supabase
+ .from('*')
+ .on('*', payload => {
+ console.log('Change received!', payload)
+ })
+ .subscribe()
+`
+
+export const subscribeTableJs = `
+import { createClient } from '@supabase/supabase-js'
+
+// Create a single supabase client for interacting with your database
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+// Listen to changes
+const mySubscription = supabase
+ .from('countries')
+ .on('*', payload => {
+ console.log('Change received!', payload)
+ })
+ .subscribe()
+`
+
+export const subscribeInsertsJs = `
+import { createClient } from '@supabase/supabase-js'
+
+// Create a single supabase client for interacting with your database
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+// Listen to changes
+const mySubscription = supabase
+ .from('countries')
+ .on('INSERT', payload => {
+ console.log('Change received!', payload)
+ })
+ .subscribe()
+`
+
+export const subscribeUpdatesJs = `
+import { createClient } from '@supabase/supabase-js'
+
+// Create a single supabase client for interacting with your database
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+// Listen to changes
+const mySubscription = supabase
+ .from('countries')
+ .on('UPDATE', payload => {
+ console.log('Change received!', payload)
+ })
+ .subscribe()
+`
+
+export const subscribeDeletesJs = `
+import { createClient } from '@supabase/supabase-js'
+
+// Create a single supabase client for interacting with your database
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+// Listen to changes
+const mySubscription = supabase
+ .from('countries')
+ .on('DELETE', payload => {
+ console.log('Change received!', payload)
+ })
+ .subscribe()
+`
+
+export const subscribeMultipleJs = `
+import { createClient } from '@supabase/supabase-js'
+
+// Create a single supabase client for interacting with your database
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+// Listen to changes
+const mySubscription = supabase
+ .from('countries')
+ .on('INSERT', handleRecordInserted)
+ .on('DELETE', handleRecordDeleted)
+ .subscribe()
+`
+
+export const subscribeUnsubscribeJs = `
+import { createClient } from '@supabase/supabase-js'
+
+// Create a single supabase client for interacting with your database
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+// Listen to changes
+const mySubscription = supabase
+ .from('countries')
+ .on('*', payload => {
+ console.log('Change received!', payload)
+ })
+ .subscribe()
+
+// Unsubscribe from changes
+mySubscription.unsubscribe()
+`
+
+export const subscribeRemoveJs = `
+import { createClient } from '@supabase/supabase-js'
+
+// Create a single supabase client for interacting with your database
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+// Listen to changes
+const mySubscription = supabase
+ .from('countries')
+ .on('*', payload => {
+ console.log('Change received!', payload)
+ })
+ .subscribe()
+
+// Disconnect mySubscription
+supabase.removeSubscription(mySubscription)
+`
+
+/**
+ * get.mdx examples
+ */
export const getSimpleJs = `
import { createClient } from '@supabase/supabase-js'
@@ -74,4 +206,148 @@ const getProducts = async () => {
console.log('Error: ', error)
}
}
-`
\ No newline at end of file
+`
+
+/**
+ * post.mdx examples
+ */
+
+export const postSingleJs = `
+import { createClient } from '@supabase/supabase-js'
+
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+const getCities = async () => {
+ try {
+ let cities = await supabase
+ .from('cities')
+ .insert([
+ { name: 'The Shire', country_id: 554 }
+ ])
+ return cities
+ } catch (error) {
+ console.log('Error: ', error)
+ }
+}
+`
+
+export const postBulkJs = `
+import { createClient } from '@supabase/supabase-js'
+
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+const createCities = async () => {
+ try {
+ let cities = await supabase
+ .from('cities')
+ .insert([
+ { name: 'The Shire', country_id: 554 },
+ { name: 'Rohan', country_id: 554 },
+ ])
+ return cities
+ } catch (error) {
+ console.log('Error: ', error)
+ }
+}
+`
+
+/**
+ * patch.mdx examples
+ */
+
+export const patchRecordJs = `
+import { createClient } from '@supabase/supabase-js'
+
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+const updateCountryName = async () => {
+ try {
+ let updates = await supabase
+ .from('countries')
+ .udpate({ name: 'Middle Earth' })
+ .match({ name: 'New Zealand' })
+
+ return updates
+ } catch (error) {
+ console.log('Error: ', error)
+ }
+}
+`
+
+/**
+ * delete.mdx examples
+ */
+
+export const deleteRecordJs = `
+import { createClient } from '@supabase/supabase-js'
+
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+const updateCountryName = async () => {
+ try {
+ let values = await supabase
+ .from('cities')
+ .match({ id: 666 })
+ .delete()
+
+ return values
+ } catch (error) {
+ console.log('Error: ', error)
+ }
+}
+`
+
+/**
+ * stored-procedures.mdx examples
+ */
+
+export const storedSingleJs = `
+import { createClient } from '@supabase/supabase-js'
+
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+const echoCity = async () => {
+ try{
+ let city = await supabase
+ .rpc('echo_city', { name: 'The Shire' })
+ return cities
+ } catch (error) {
+ console.log('Error: ', error)
+ }
+}
+`
+
+export const storedBulkJs = `
+import { createClient } from '@supabase/supabase-js'
+
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+const echoCities = async () => {
+ try{
+ let cities = await supabase
+ .rpc('echo_city', [
+ { name: 'The Shire' },
+ { name: 'Mordor' }
+ ])
+ return cities
+ } catch (error) {
+ console.log('Error: ', error)
+ }
+}
+`
+
+export const storedReadingJs = `
+import { createClient } from '@supabase/supabase-js'
+
+const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+
+const echoCities = async () => {
+ try{
+ let cities = await supabase
+ .rpc('asian_pacific_countries')
+ return cities
+ } catch (error) {
+ console.log('Error: ', error)
+ }
+}
+`
diff --git a/web/docs/library/patch.mdx b/web/docs/library/patch.mdx
index 991cbd954fa..047440509f4 100644
--- a/web/docs/library/patch.mdx
+++ b/web/docs/library/patch.mdx
@@ -10,39 +10,24 @@ import Collapsable from '../../src/components/Collapsable'
import CommonResponses from '../common/CommonResponses.mdx'
import CommonFilters from '../common/CommonFilters'
import FromFunction from '../common/FromFunction.mdx'
+import CustomCodeBlock from '../../src/components/CustomCodeBlock'
+import { patchRecordJs } from './getExamples'
<DummyData />
### Update record
-This example how to update a country:
-
-<!-- prettier-ignore -->
-```js {7-10}
-import { createClient } from '@supabase/supabase-js'
-
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-const updateCountryName = async () => {
- try {
- let updates = await supabase
- .from('countries')
- .udpate({ name: 'Middle Earth' })
- .match({ name: 'New Zealand' })
-
- return updates
- } catch (error) {
- console.log('Error: ', error)
- }
-}
-```
-
-<Collapsable title="Toggle Example Response">
-
-@todo
-
-</Collapsable>
-
+<CustomCodeBlock
+ header="Updates information about a city."
+ js={patchRecordJs}
+ jsHighlight="{7-10}"
+ response={`{
+ "body": null,
+ "status": 204,
+ "statusCode": 204,
+ "statusText": "No Content"
+}`}
+/>
## Reference
diff --git a/web/docs/library/post.mdx b/web/docs/library/post.mdx
index cbaa52d9446..58afddd90b3 100644
--- a/web/docs/library/post.mdx
+++ b/web/docs/library/post.mdx
@@ -9,6 +9,8 @@ import DummyData from '../common/DummyData.mdx'
import Collapsable from '../../src/components/Collapsable'
import CommonResponses from '../common/CommonResponses.mdx'
import FromFunction from '../common/FromFunction.mdx'
+import CustomCodeBlock from '../../src/components/CustomCodeBlock'
+import { postSingleJs, postBulkJs } from './getExamples'
<DummyData />
@@ -16,67 +18,31 @@ import FromFunction from '../common/FromFunction.mdx'
### Create a record
-This example how to create a new city:
-
-<!-- prettier-ignore -->
-```js {7-11}
-import { createClient } from '@supabase/supabase-js'
-
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-const getCities = async () => {
- try {
- let cities = await supabase
- .from('cities')
- .insert([
- { name: 'The Shire', country_id: 554 }
- ])
- return cities
- } catch (error) {
- console.log('Error: ', error)
- }
-}
-```
-
-<Collapsable title="Toggle Example Response">
-
-@todo
-
-</Collapsable>
+<CustomCodeBlock
+ header="Creates a new city."
+ js={postSingleJs}
+ jsHighlight="{7-11}"
+ response={`{
+ "body": null,
+ "status": 201,
+ "statusCode": 201,
+ "statusText": "Created"
+}`}
+/>
### Bulk create
-This example how to create multiple cities with one request:
-
-<!-- prettier-ignore -->
-```js {7-12}
-import { createClient } from '@supabase/supabase-js'
-
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-const createCities = async () => {
- try {
- let cities = await supabase
- .from('cities')
- .insert([
- { name: 'The Shire', country_id: 554 },
- { name: 'Rohan', country_id: 554 },
- ])
- return cities
- } catch (error) {
- console.log('Error: ', error)
- }
-}
-```
-
-<Collapsable title="Toggle Example Response">
-
-@todo
-
-</Collapsable>
-
-
-
+<CustomCodeBlock
+ header="Creates a multiple new cities."
+ js={postBulkJs}
+ jsHighlight="{7-12}"
+ response={`{
+ "body": null,
+ "status": 201,
+ "statusCode": 201,
+ "statusText": "Created"
+}`}
+/>
## Reference
diff --git a/web/docs/library/stored-procedures.mdx b/web/docs/library/stored-procedures.mdx
index 4a8d9a10290..6137bba9af4 100644
--- a/web/docs/library/stored-procedures.mdx
+++ b/web/docs/library/stored-procedures.mdx
@@ -8,6 +8,8 @@ import Collapsable from '../../src/components/Collapsable'
import CommonFilters from '../common/CommonFilters'
import CommonResponses from '../common/CommonResponses.mdx'
import DummyData from '../common/DummyData.mdx'
+import CustomCodeBlock from '../../src/components/CustomCodeBlock'
+import { storedSingleJs, storedBulkJs, storedReadingJs } from './getExamples'
You can call stored procedures as a "Remote Procedure Call".
@@ -18,100 +20,60 @@ This is especially useful when the logic rarely changes - like password resets a
### Single call
-This example shows how to call a stored function that takes in a name of a city and returns it:
-
-<!-- prettier-ignore -->
-```js {7-8}
-import { createClient } from '@supabase/supabase-js'
-
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-const echoCity = async () => {
- try{
- let city = await supabase
- .rpc('echo_city', { name: 'The Shire' })
- return cities
- } catch (error) {
- console.log('Error: ', error)
- }
-}
-```
-
-<Collapsable title="Toggle Example Response">
-
-```json
-[
- {echo_city: "The Shire"}
-]
-```
-
-</Collapsable>
+<CustomCodeBlock
+ header="Example of invoking a stored procedure that taking in a name of a city and returning it."
+ js={storedSingleJs}
+ jsHighlight="{7-8}"
+ response={`{
+ "body": [
+ {"echo_city": "The Shire"}
+ ],
+ "status": 200,
+ "statusCode": 200,
+ "statusText": "OK"
+}
+ `}
+/>
### Bulk call
This example would call a the same stored procedure above (twice), but it will also wait to receive the response only when all the calls have completed:
-<!-- prettier-ignore -->
-```js {7-11}
-import { createClient } from '@supabase/supabase-js'
-
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-const echoCities = async () => {
- try{
- let cities = await supabase
- .rpc('echo_city', [
- { name: 'The Shire' },
- { name: 'Mordor' }
- ])
- return cities
- } catch (error) {
- console.log('Error: ', error)
- }
-}
-```
-
-<Collapsable title="Toggle Example Response">
-
-```json
-[
- {echo_city: "The Shire"},
- {echo_city: "Mordor"}
-]
-```
-
-</Collapsable>
+<CustomCodeBlock
+ header="Example of invoking the same stored procedure multiple times within one call."
+ js={storedBulkJs}
+ jsHighlight="{7-11}"
+ response={`{
+ "body": [
+ {"echo_city": "The Shire"},
+ {"echo_city": "Mordor"}
+ ],
+ "status": 200,
+ "statusCode": 200,
+ "statusText": "OK"
+}
+ `}
+/>
### Reading data
This example shows how to call a stored function that returns a table type response:
-<!-- prettier-ignore -->
-```js {7-8}
-import { createClient } from '@supabase/supabase-js'
-
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-const echoCities = async () => {
- try{
- let cities = await supabase
- .rpc('asian_pacific_countries')
- return cities
- } catch (error) {
- console.log('Error: ', error)
- }
-}
-```
-
-<Collapsable title="Toggle Example Response">
-
-```json
-[
- {id: 156, name: "China", iso2: "CN", continent: "Asia"},
- {id: 554, name: "New Zealand", iso2: "NZ", continent: "Oceania"}
-]
-```
-</Collapsable>
+<CustomCodeBlock
+ header="Example of invoking the same stored procedure multiple times within one call."
+ js={storedReadingJs}
+ jsHighlight="{7-8}"
+ response={`{
+ "body": [
+ {"id": 156, "name": "China", "iso2": "CN", "continent": "Asia"},
+ {"id": 554, "name": "New Zealand", "iso2": "NZ", "continent": "Oceania"}
+ ],
+ "status": 200,
+ "statusCode": 200,
+ "statusText": "OK"
+}
+ `}
+/>
## Reference
diff --git a/web/docs/library/subscribe.mdx b/web/docs/library/subscribe.mdx
index f97628c0b63..f7d2c9f669e 100644
--- a/web/docs/library/subscribe.mdx
+++ b/web/docs/library/subscribe.mdx
@@ -7,6 +7,8 @@ description: 'Subscribe to realtime changes in your database with Supabase'
import DummyData from '../common/DummyData.mdx'
import FromFunction from '../common/FromFunction.mdx'
import Collapsable from '../../src/components/Collapsable'
+import CustomCodeBlock from '../../src/components/CustomCodeBlock'
+import { subscribeAllJs, subscribeTableJs, subscribeInsertsJs, subscribeUpdatesJs, subscribeDeletesJs, subscribeMultipleJs, subscribeUnsubscribeJs, subscribeRemoveJs } from './getExamples'
Subscribe to realtime changes in your own database.
@@ -16,152 +18,67 @@ We will be using these tables as reference for our examples.
### Listen to all database changes
-<!-- prettier-ignore -->
-```js {8}
-import { createClient } from '@supabase/supabase-js'
-
-// Create a single supabase client for interacting with your database
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-// Listen to changes
-const mySubscription = supabase
- .from('*')
- .on('*', payload => {
- console.log('Change received!', payload)
- })
- .subscribe()
-```
+<CustomCodeBlock
+ header="Subscribes to all database changes in realtime."
+ js={subscribeAllJs}
+ jsHighlight="{8}"
+/>
### Listening to a specific table
-<!-- prettier-ignore -->
-```js {8}
-import { createClient } from '@supabase/supabase-js'
+<CustomCodeBlock
+ header="Subscribes to a specific table for changes in realtime."
+ js={subscribeTableJs}
+ jsHighlight="{8}"
+/>
-// Create a single supabase client for interacting with your database
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+### Listening only to INSERT
-// Listen to changes
-const mySubscription = supabase
- .from('countries')
- .on('*', payload => {
- console.log('Change received!', payload)
- })
- .subscribe()
-```
+<CustomCodeBlock
+ header="Subscribes only to the INSERT event."
+ js={subscribeInsertsJs}
+ jsHighlight="{9-11}"
+/>
-### Listening only to INSERTS
-
-<!-- prettier-ignore -->
-```js {9-11}
-import { createClient } from '@supabase/supabase-js'
+### Listening only to UPDATE
-// Create a single supabase client for interacting with your database
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
+<CustomCodeBlock
+ header="Subscribes only to the UPDATE event."
+ js={subscribeUpdatesJs}
+ jsHighlight="{9-11}"
+/>
-// Listen to changes
-const mySubscription = supabase
- .from('countries')
- .on('INSERT', payload => {
- console.log('Change received!', payload)
- })
- .subscribe()
-```
+### Listening only to DELETE
-### Listening only to UPDATES
-
-<!-- prettier-ignore -->
-```js {9-11}
-import { createClient } from '@supabase/supabase-js'
-
-// Create a single supabase client for interacting with your database
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-// Listen to changes
-const mySubscription = supabase
- .from('countries')
- .on('UPDATE', payload => {
- console.log('Change received!', payload)
- })
- .subscribe()
-```
-
-### Listening only to DELETES
-
-<!-- prettier-ignore -->
-```js {9-11}
-import { createClient } from '@supabase/supabase-js'
-
-// Create a single supabase client for interacting with your database
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-// Listen to changes
-const mySubscription = supabase
- .from('countries')
- .on('DELETE', payload => {
- console.log('Change received!', payload)
- })
- .subscribe()
-```
+<CustomCodeBlock
+ header="Subscribes only to the DELETE event."
+ js={subscribeDeletesJs}
+ jsHighlight="{9-11}"
+/>
### Listening to multiple events
-<!-- prettier-ignore -->
-```js {9-10}
-import { createClient } from '@supabase/supabase-js'
-
-// Create a single supabase client for interacting with your database
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-// Listen to changes
-const mySubscription = supabase
- .from('countries')
- .on('INSERT', handleRecordInserted)
- .on('DELETE', handleRecordDeleted)
- .subscribe()
-```
-
-### Removing a subscription
-
-<!-- prettier-ignore -->
-```js {15}
-import { createClient } from '@supabase/supabase-js'
-
-// Create a single supabase client for interacting with your database
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-// Listen to changes
-const mySubscription = supabase
- .from('countries')
- .on('*', payload => {
- console.log('Change received!', payload)
- })
- .subscribe()
-
-// Unsubscribe from changes
-mySubscription.unsubscribe()
-```
+<CustomCodeBlock
+ header="Subscribes to multiple but not all events."
+ js={subscribeMultipleJs}
+ jsHighlight="{9-10}"
+/>
### Unsubscribing
-<!-- prettier-ignore -->
-```js {15}
-import { createClient } from '@supabase/supabase-js'
+<CustomCodeBlock
+ header="Unsubscribes from a specific subscription."
+ js={subscribeUnsubscribeJs}
+ jsHighlight="{15}"
+/>
-// Create a single supabase client for interacting with your database
-const supabase = createClient('https://world.supabase.co', '1a2b-3c4d-5e6f-7g8h')
-
-// Listen to changes
-const mySubscription = supabase
- .from('countries')
- .on('*', payload => {
- console.log('Change received!', payload)
- })
- .subscribe()
+### Removing a subscription
-// Disconnect mySubscription
-supabase.removeSubscription(mySubscription)
-```
+<CustomCodeBlock
+ header="Disconnects from a subscription fully."
+ js={subscribeRemoveJs}
+ jsHighlight="{15}"
+/>
## Reference
@@ -291,9 +208,17 @@ Upon inserting or creating a new row, the following will be returned by our list
```json
{
- "eventType": "INSERT",
- "new": { "name": "Middle Earth", "country_id": "554" }
-}
+ "schema": "public",
+ "table": "countries",
+ "commit_timestamp": "2020-01-01T00:00:00Z",
+ "eventType": "INSERT",
+ "new":{
+ "id": 533,
+ "name": "Aruba",
+ "iso2": "AW",
+ "continent": "South America"
+ }
+ }
```
### Existing record updated
@@ -303,10 +228,18 @@ Upon updating a row, the following will be returned by our listener:
`
```json
{
- "eventType": "UPDATE",
- "old": { "name": "Middle Earth", "country_id": "554" },
- "new": { "name": "Wellington", "country_id": "554" }
-}
+ "schema": "public",
+ "table": "countries",
+ "commit_timestamp": "2020-01-01T00:00:00Z",
+ "eventType": "UPDATE",
+ "old":{},
+ "new":{
+ "id": 76,
+ "name": "Brazil",
+ "iso2": "BR",
+ "continent": "South America"
+ }
+ }
```
### Existing record deleted
@@ -316,7 +249,12 @@ Upon deleting a row, the following will be returned by our listener:
```json
{
- "eventType": "DELETE",
- "old": { "name": "Mordor", "country_id": "554" }
-}
+ "schema": "public",
+ "table": "countries",
+ "commit_timestamp": "2020-01-01T00:00:00Z",
+ "eventType": "DELETE",
+ "old":{
+ "id": 76
+ },
+ }
```
diff --git a/web/package-lock.json b/web/package-lock.json
index 47c3aecaa8b..ae6f571540f 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "supabase",
- "version": "0.0.0",
+ "version": "0.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -3676,9 +3676,9 @@
},
"dependencies": {
"rimraf": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.0.tgz",
- "integrity": "sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg==",
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.1.tgz",
+ "integrity": "sha512-IQ4ikL8SjBiEDZfk+DFVwqRK8md24RWMEJkdSlgNLkyyAImcjf8SWvU1qFMDOb4igBClbTQ/ugPqXcRwdFTxZw==",
"requires": {
"glob": "^7.1.3"
}
@@ -4515,9 +4515,9 @@
}
},
"follow-redirects": {
- "version": "1.9.1",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.9.1.tgz",
- "integrity": "sha512-oUNbrdUjHItyCytZQrHxWQ81ebL4xCFLH10sG0poUMgbKWoBnswpICjUBld3PLJ1lF6cCYVUBG7hAdLro0JNvg==",
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.10.0.tgz",
+ "integrity": "sha512-4eyLK6s6lH32nOvLLwlIOnr9zrL8Sm+OvW4pVTJNoXeGzYIkHVf+pADQi+OJ0E67hiuSLezPVPyBcIZO50TmmQ==",
"requires": {
"debug": "^3.0.0"
},
@@ -6795,9 +6795,9 @@
"integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A=="
},
"levenary": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/levenary/-/levenary-1.1.0.tgz",
- "integrity": "sha512-VHcwhO0UTpUW7rLPN2/OiWJdgA1e9BqEDALhrgCe/F+uUJnep6CoUsTzMeP8Rh0NGr9uKquXxqe7lwLZo509nQ==",
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/levenary/-/levenary-1.1.1.tgz",
+ "integrity": "sha512-mkAdOIt79FD6irqjYSs4rdbnlT5vRonMEvBVPVb3XmevfS8kgRXwfes0dhPdEtzTWD/1eNE/Bm/G1iRt6DcnQQ==",
"requires": {
"leven": "^3.1.0"
}
@@ -9623,14 +9623,14 @@
"integrity": "sha512-PeNBa8iuzoD7qHA9O7YpGnXFvC+XFFwStmFh2/r2zJAvEIaRg6EwOj+EPcDIFwyYBhqPIItxIx/dGdeWiFivjQ=="
},
"react-helmet": {
- "version": "6.0.0-beta",
- "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.0.0-beta.tgz",
- "integrity": "sha512-GnNWsokebTe7fe8MH2I/a2dl4THYWhthLBoMaQSRYqW5XbPo881WAJGi+lqRBjyOFryW6zpQluEkBy70zh+h9w==",
+ "version": "6.0.0-beta.2",
+ "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.0.0-beta.2.tgz",
+ "integrity": "sha512-rRAeil8HsddijqG2+1jeR5qY9wGQvK1zPMf+8MkiTCyhpEP/2qhAAPolEsveeAlz0xSv5C5xYypHtgCtFn0euw==",
"requires": {
"object-assign": "^4.1.1",
- "prop-types": "^15.5.4",
- "react-fast-compare": "^2.0.2",
- "react-side-effect": "^1.1.0"
+ "prop-types": "^15.7.2",
+ "react-fast-compare": "^2.0.4",
+ "react-side-effect": "^2.1.0"
}
},
"react-inlinesvg": {
@@ -9741,12 +9741,9 @@
}
},
"react-side-effect": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-1.2.0.tgz",
- "integrity": "sha512-v1ht1aHg5k/thv56DRcjw+WtojuuDHFUgGfc+bFHOWsF4ZK6C2V57DO0Or0GPsg6+LSTE0M6Ry/gfzhzSwbc5w==",
- "requires": {
- "shallowequal": "^1.0.1"
- }
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.0.tgz",
+ "integrity": "sha512-IgmcegOSi5SNX+2Snh1vqmF0Vg/CbkycU9XZbOHJlZ6kMzTmi3yc254oB1WCkgA7OQtIAoLmcSFuHTc/tlcqXg=="
},
"react-smooth": {
"version": "1.0.5",
@@ -10544,11 +10541,6 @@
"safe-buffer": "^5.0.1"
}
},
- "shallowequal": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz",
- "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ=="
- },
"shebang-command": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",