From 2ef4d8133ac4ce6e352e79d4c856e2dc1e7741e8 Mon Sep 17 00:00:00 2001 From: Paul Copplestone Date: Sun, 17 Jan 2021 15:01:58 +0800 Subject: [PATCH] docs: add comments for deleted subscriptions --- web/docs/client/generating-types.mdx | 14 +++++++------- web/docs/client/subscribe.mdx | 4 ++++ web/spec/supabase.yml | 20 +++++++++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/web/docs/client/generating-types.mdx b/web/docs/client/generating-types.mdx index 0c500e387f5..cc012a97f37 100644 --- a/web/docs/client/generating-types.mdx +++ b/web/docs/client/generating-types.mdx @@ -12,9 +12,9 @@ Supabase will soon release native type generators that dump your database types ## Usage with TypeScript -`supabase-js` ships with type definitions for usage with TypeScript and for convenient IntelliSense autocomplete and documentation in your editor. +`supabase-js` ships with type definitions for usage with TypeScript and for convenient IntelliSense auto-complete and documentation in your editor. -When using TypeScript, you can pass the type of database row as a type parameter to the `from` method to get better autocompletion support down the chain. +When using TypeScript, you can pass the type of database row as a type parameter to the `from` method to get better auto-completion support down the chain. If you don't provide a type for the row you need to explicitly pass `from('tableName')`. ```ts @@ -25,13 +25,13 @@ type Message = { user_id: string; channel_id: number; author: { username: string }; -}; +} const response = await supabase .from('messages') // Message maps to the type of the row in your database. .select('*, author:user_id(username)') - .match({ channel_id: 2 }) // Your IDE will be able to help with automcompletion. -response.data // Response body will be of type Array. + .match({ channel_id: 2 }) // Your IDE will be able to help with auto-completion. +response.data // Response data will be of type Array. // If you don't provide a type for the row you need to explicitly pass `from('tableName')`. const response = await supabase @@ -51,10 +51,10 @@ The Swagger specification for your Supabase project can be accessed as follows: https://your-project.supabase.co/rest/v1/?apikey=your-anon-key ``` -Using the open source [swagger-to-ts](https://github.com/drwpow/openapi-typescript#%EF%B8%8F-reading-specs-from-remote-resource) tool you can generate your types and store them locally: +Using the open source [swagger-to-ts](https://github.com/manifoldco/swagger-to-ts#%EF%B8%8F-reading-specs-from-remote-resource) tool you can generate your types and store them locally: ```bash -npx openapi-typescript https://your-project.supabase.co/rest/v1/?apikey=your-anon-key --output types/supabase.ts +npx @manifoldco/swagger-to-ts https://your-project.supabase.co/rest/v1/?apikey=your-anon-key --output types/supabase.ts ``` **Note:** Do note that your local types won't automatically stay in sync with your database, so make sure to regenerate your types after your make changes to your database. diff --git a/web/docs/client/subscribe.mdx b/web/docs/client/subscribe.mdx index 85b3dd2a99e..ee2db72f550 100644 --- a/web/docs/client/subscribe.mdx +++ b/web/docs/client/subscribe.mdx @@ -204,6 +204,8 @@ const mySubscription = supabase ### Listening to updates +By default Supabase will send only the updated record. If you want to receive the previous values as well you can +enable full replication for the table you are listening too: `alter table "your_table" replica identity full;` ('tableName')`. ```ts @@ -162,20 +162,20 @@ pages: user_id: string; channel_id: number; author: { username: string }; - }; + } const response = await supabase .from('messages') // Message maps to the type of the row in your database. .select('*, author:user_id(username)') - .match({ channel_id: 2 }); // Your IDE will be able to help with automcompletion. - response.body // Response body will be of type Array. + .match({ channel_id: 2 }) // Your IDE will be able to help with auto-completion. + response.data // Response data will be of type Array. // If you don't provide a type for the row you need to explicitly pass `from('tableName')`. const response = await supabase .from('messages') .select('*, author:user_id(username)') - .match({ channel_id: 2 }); - response.body // Response body will be of type Array. + .match({ channel_id: 2 }) + response.data // Response data will be of type Array. ``` ### Generate database types from Swagger OpenAPI specification @@ -713,6 +713,9 @@ pages: # Not yet implemented ``` - name: Listening to updates + description: | + By default Supabase will send only the updated record. If you want to receive the previous values as well you can + enable full replication for the table you are listening too: `alter table "your_table" replica identity full;` js: | ```js const mySubscription = supabase @@ -727,6 +730,9 @@ pages: # Not yet implemented ``` - name: Listening to deletes + description: | + By default Supabase not send deleted records. If you want to receive the deleted record you can + enable full replication for the table you are listening too: `alter table "your_table" replica identity full;` js: | ```js const mySubscription = supabase