tdwcks
09/12/2021, 9:09 AMdreinon
09/12/2021, 3:54 PMdreinon
09/12/2021, 3:54 PMdreinon
09/12/2021, 3:56 PMdreinon
09/12/2021, 3:57 PMNOTIFY pgrst, 'reload schema'
and also tried to create an event trigger to restart the scheme cache automatically with:
-- Create an event trigger function
CREATE OR REPLACE FUNCTION public.pgrst_watch() RETURNS event_trigger
LANGUAGE plpgsql
AS $$
BEGIN
NOTIFY pgrst, 'reload schema';
END;
$$;
-- This event trigger will fire after every ddl_command_end event
CREATE EVENT TRIGGER pgrst_watch
ON ddl_command_end
EXECUTE PROCEDURE public.pgrst_watch();
Brock
09/12/2021, 10:15 PMjs
await supabase.from('profiles').select(`
id,
first_name,
last_name,
assigned_departments
But what I would like to do is use the UUID foreign key for the assigned_departments and query the department name. I tried the following:
js
await supabase.from('profiles').select(`
id,
first_name,
last_name,
assigned_departments (
id
department_name
)
But I get this error message as a response.
js
{
"hint": "If a new foreign key between these entities was created in the database, try reloading the schema cache.",
"message": "Could not find a relationship between profiles and assigned_departments in the schema cache"
}
I'm not sure how to reload the scheme cache or if I am just missing something?dreinon
09/12/2021, 10:21 PMdreinon
09/12/2021, 10:22 PMBrock
09/12/2021, 10:23 PMconst { data, error } = await supabase
.from('countries')
.select(`
name,
cities (
name
)
`)
RichCorbs
09/12/2021, 10:53 PMassigned_departments!assigned_department(*)
.Brock
09/12/2021, 10:59 PMBrock
09/12/2021, 11:19 PMlet { data: profiles, error } = await supabase.from('profiles').select(`
id,
first_name,
last_name,
assigned_departments (
id,
department_name
)
`);
Brock
09/12/2021, 11:31 PMerik_flywheel
09/13/2021, 1:11 AMdreinon
09/13/2021, 1:43 AMjason-lynx
09/13/2021, 1:48 AMjason-lynx
09/13/2021, 1:50 AMUNNEST
in postgres https://www.postgresql.org/docs/current/functions-array.htmleverconfusedguy
09/13/2021, 1:53 AMBrock
09/13/2021, 1:57 AMjason-lynx
09/13/2021, 2:05 AMBrock
09/13/2021, 2:08 AMassigned_depts
is one or many departments?Brock
09/13/2021, 2:09 AMjason-lynx
09/13/2021, 2:23 AMuser
09/13/2021, 2:33 AMstibbs
09/13/2021, 3:13 AMauth.users
table does have a role
column, but I think it is used more as a boolean for whether the user has validated their email?
If you want to add roles, add your own public.users
table and add the fields there, with link to the auth.users
idstibbs
09/13/2021, 3:15 AMselect * from auth.users;
in the supabase SQL uilnraahCC
09/13/2021, 4:02 AMMiguel
09/13/2021, 6:26 AMjmnoz
09/13/2021, 7:43 AMstibbs
09/13/2021, 7:46 AM