garyaustin
07/26/2022, 8:26 PMauth.uid() = ANY (array_col)
Nin
07/27/2022, 9:16 PMNin
07/27/2022, 9:31 PMRelisora
07/28/2022, 1:27 AMgaryaustin
07/28/2022, 1:27 AMRelisora
07/28/2022, 1:28 AMdrewbie
07/28/2022, 9:02 PMuser_metadata
object on an auth user? I can see the data is saved/returned back with the auth user if I pass in custom data to an auth call, but I am trying to add some of the meta data to my create user function that triggers with a new auth user is created. So far I havent been able to get it to work and I think its due to the way Im trying to access the property -> new.user_metadata.source
create function public.init_profile_from_auth_user()
returns trigger
language plpgsql
security definer set search_path = public
as $$
declare
merchant_id uuid;
shop_id uuid;
begin
merchant_id := extensions.uuid_generate_v4();
shop_id := extensions.uuid_generate_v4();
insert into public.merchants(id)
values(merchant_id);
insert into public.shops(id, merchant_id)
values(shop_id, merchant_id);
insert into public.users (id, email, shop_id, source)
values (new.id, new.email, shop_id, new.user_metadata.source);
return new;
end;
$$;
garyaustin
07/28/2022, 9:10 PMdrewbie
07/28/2022, 11:51 PMsylar815
07/29/2022, 5:48 AMgaryaustin
07/29/2022, 12:37 PMleviwhalen
07/29/2022, 8:23 PMmembers
, teams
and sites
-- and I would like to be able to select member_id
, team_id
and an array of that team's `site_id`s. I'm still learning SQL -- is there a resource someone can point me to in order to return `site_id`s as an array in one row instead of separate rows with duplicate member and team data? Thanks!sylar815
07/30/2022, 6:38 AM(select branchcode, sum(valuein) as my_sum from db where datetime between {{ moment(dateSelector.value).format('YYYY-MM-DD') }} and {{ moment(dateSelector.value).format('YYYY-MM-DD') }} group by branchcode ORDER BY "branchcode" ASC)
and
(select branchcode, sum(valuein) as my_sum_weekly from db where datetime between {{ moment(dateSelector.value).startOf('week').format('YYYY-MM-DD') }} and {{moment(dateSelector.value).format("YYYY-MM-DD")}}group by branchcode ORDER BY "branchcode" ASC)
how do i combine the results vertically
branchcode | my_sum | branchcode | my_sum_weekly
any ideas?iLikeBikes
07/31/2022, 6:02 PMuser_profiles
and agencies
the user_profiles
have a shared key of agency_id
which is a uuid
I have looked a little bit in the Postgres docs and haven't been able to come up with much. Is there a good way to convert the below statement into an RLS ?
select email, user_id, ag.agency_id
from auth.users u
join user_profiles up on up.user_id = u.id
left join agencies ag on ag.agency_id = up.agency_id
garyaustin
07/31/2022, 6:18 PMiLikeBikes
07/31/2022, 6:53 PMs c a p e g o a t
07/31/2022, 7:27 PMjavascript
supabase
.from("items")
.select(`
name,
type:types (
name
),
price:types (
price
)
`)
.csv()
If possible, I want to get the values from the relationships (type
and price
from the table types
using the database without having to process this again using JS so that I can get the CSV directly from supabase DB.
I'm not sure what terms to look for. Still getting used to Postgres and PostgREST.iLikeBikes
07/31/2022, 9:03 PMSmirnovious
08/01/2022, 7:44 PMgaryaustin
08/01/2022, 7:54 PMSmirnovious
08/01/2022, 7:54 PMgaryaustin
08/01/2022, 8:00 PMHuntedman
08/02/2022, 6:55 AMsql
('training.view'::text IN (
SELECT test_permission.app_permission FROM test_permission)
)
Data in test_permission:Huntedman
08/02/2022, 6:57 AMHuntedman
08/02/2022, 1:08 PMmrwinbush
08/02/2022, 8:08 PMdrewbie
08/03/2022, 4:07 PMJomatom
08/03/2022, 4:17 PMcreate policy "Team members can update team details if they belong to the team."
on teams
for update using (
auth.uid() in (
select user_id from members
where team_id = id
)
);
Now I want to create a rls for the third table which is also connected via a foreign key to the second table.
table1 table2 table3
How can I apply the example above to join the second table first and then the first where I can access the user_id?Smirnovious
08/04/2022, 8:33 AMSmirnovious
08/04/2022, 8:33 AM