Skip to content

Commit

Permalink
chore: added some contents to readme of example folder
Browse files Browse the repository at this point in the history
  • Loading branch information
dshukertjr committed Aug 6, 2022
1 parent bcdd088 commit b81de78
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion example/README.md
@@ -1,4 +1,59 @@
#### Examples
# Profile Example

Basic example of how to signup/ login using Supabase auth and read and write from your Supabase database.
## SQL

You can run the following SQL from your SQL editor of your Supabase console to get started.

```sql
-- Create a table for Public Profiles
create table profiles (
id uuid references auth.users not null,
updated_at timestamp with time zone,
username text unique,
avatar_url text,
website text,

primary key (id),
unique(username),
constraint username_length check (char_length(username) >= 3)
);

alter table profiles
enable row level security;

create policy "Public profiles are viewable by everyone." on profiles
for select using (true);

create policy "Users can insert their own profile." on profiles
for insert with check (auth.uid() = id);

create policy "Users can update own profile." on profiles
for update using (auth.uid() = id);

-- Set up Realtime!
begin;
drop publication if exists supabase_realtime;
create publication supabase_realtime;
commit;
alter publication supabase_realtime
add table profiles;

-- Set up Storage!
insert into storage.buckets (id, name)
values ('avatars', 'avatars');

create policy "Avatar images are publicly accessible." on storage.objects
for select using (bucket_id = 'avatars');

create policy "Anyone can upload an avatar." on storage.objects
for insert with check (bucket_id = 'avatars');

create policy "Anyone can update an avatar." on storage.objects
for update with check (bucket_id = 'avatars');
```

## Other Examples

- Flutter user management: https://github.com/supabase/supabase/tree/master/examples/flutter-user-management
- Extended flutter user management with web support, github login, recovery password flow: https://github.com/phamhieu/supabase-flutter-demo
Expand Down

0 comments on commit b81de78

Please sign in to comment.