From ddd29b6d3883cbd8788605f1102b0f8ba46e31ad Mon Sep 17 00:00:00 2001 From: Isaiah Hamilton <70828596+Isaiah-Hamilton@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:22:07 -0400 Subject: [PATCH 1/3] updating queries on the homepage --- apps/www/data/home/api-examples.js | 84 +++++++++++++++++------------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/apps/www/data/home/api-examples.js b/apps/www/data/home/api-examples.js index 652cfaad0c5..b7a27801a21 100644 --- a/apps/www/data/home/api-examples.js +++ b/apps/www/data/home/api-examples.js @@ -39,15 +39,58 @@ const realtime = supabase }, { lang: 'js', - title: 'Read a record', - description: 'Get all public rooms and their messages', - code: `import '@supabase/supabase-js' - + title: 'Create bucket', + description: 'Creates a new Storage bucket', + code: `import { createClient } from '@supabase/supabase-js' + // Initialize const supabaseUrl = 'https://chat-room.supabase.co' const supabaseKey = 'public-anon-key' const supabase = createClient(supabaseUrl, supabaseKey) +// Create a new bucket +const { data, error } = await supabase + .storage + .createBucket('avatars', { + public: false, + allowedMimeTypes: ['image/png'], + fileSizeLimit: 1024 + }) + `, + }, + { + lang: 'js', + title: 'Invoke function', + description: 'Invoke a Supabase Function', + code: `import { createClient } from '@supabase/supabase-js' + +// Initialize +const supabaseUrl = 'https://chat-room.supabase.co' +const supabaseKey = 'public-anon-key' +const supabase = createClient(supabaseUrl, supabaseKey) + +// Invoke a function +const { data, error } = await supabase.functions.invoke('hello', { + body: { foo: 'bar' } +}) + `, + }, + { + lang: 'js', + title: 'CRUD a record', + description: 'Create, Read, Update and Delete all public rooms and their messages', + code: `import { createClient } from '@supabase/supabase-js' + +// Initialize +const supabaseUrl = 'https://chat-room.supabase.co' +const supabaseKey = 'public-anon-key' +const supabase = createClient(supabaseUrl, supabaseKey) + +// Create a new chat room +const newRoom = await supabase + .from('rooms') + .insert({ name: 'Supabase Fan Club', public: true }) + // Get public rooms and their messages const publicRooms = await supabase .from('rooms') @@ -56,41 +99,12 @@ const publicRooms = await supabase messages ( text ) \`) .eq('public', true) - `, - }, - { - lang: 'js', - title: 'Create a record', - description: 'Create a new chat room', - code: `import { createClient } from '@supabase/supabase-js' - -// Initialize -const supabaseUrl = 'https://chat-room.supabase.co' -const supabaseKey = 'public-anon-key' -const supabase = createClient(supabaseUrl, supabaseKey) - -// Create a new chat room -const newRoom = await supabase - .from('rooms') - .insert({ name: 'Supabase Fan Club', public: true }) - `, - }, - { - lang: 'js', - title: 'Update a record', - description: 'Update a user', - code: `import { createClient } from '@supabase/supabase-js' - -// Initialize -const supabaseUrl = 'https://chat-room.supabase.co' -const supabaseKey = 'public-anon-key' -const supabase = createClient(supabaseUrl, supabaseKey) - + // Update multiple users const updatedUsers = await supabase .from('users') .eq('account_type', 'paid') .update({ highlight_color: 'gold' }) -`, + `, }, ] From 79b8efa37238fe5b86af5fcadf66ed72041a03d5 Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Fri, 30 Jun 2023 11:06:54 -0230 Subject: [PATCH 2/3] Update apps/www/data/home/api-examples.js --- apps/www/data/home/api-examples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/www/data/home/api-examples.js b/apps/www/data/home/api-examples.js index b7a27801a21..143039bd99f 100644 --- a/apps/www/data/home/api-examples.js +++ b/apps/www/data/home/api-examples.js @@ -60,7 +60,7 @@ const { data, error } = await supabase }, { lang: 'js', - title: 'Invoke function', + title: 'Invoke Edge Function', description: 'Invoke a Supabase Function', code: `import { createClient } from '@supabase/supabase-js' From b32bc11dd895df95ccedf838bba9b9cdce12b78d Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Fri, 30 Jun 2023 11:07:16 -0230 Subject: [PATCH 3/3] Update apps/www/data/home/api-examples.js --- apps/www/data/home/api-examples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/www/data/home/api-examples.js b/apps/www/data/home/api-examples.js index 143039bd99f..0202942bc78 100644 --- a/apps/www/data/home/api-examples.js +++ b/apps/www/data/home/api-examples.js @@ -61,7 +61,7 @@ const { data, error } = await supabase { lang: 'js', title: 'Invoke Edge Function', - description: 'Invoke a Supabase Function', + description: 'Invoke a Supabase Edge Function', code: `import { createClient } from '@supabase/supabase-js' // Initialize