mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
Merge pull request #14882 from supabase/updating-queries-on-the-homepage
Updating queries on the homepage
This commit is contained in:
1 file changed
+49
-35
@@ -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 Edge Function',
|
||||
description: 'Invoke a Supabase Edge 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' })
|
||||
`,
|
||||
`,
|
||||
},
|
||||
]
|
||||
Reference in new issue
Block a user