Hey guys, I have a table `posts` with a `user_id` ...
# javascript
j
Hey guys, I have a table
posts
with a
user_id
foreign key to
auth.users.id
and I'm trying to query the user info like this :
Copy code
js
supabase.from('posts').select('*, users(*)')
but I'm getting this error "Could not find a relationship between 'posts' and 'users' in the schema cache"
s
You can't query that table as user sensitive data is stored in it, you have to create a table in your public schema that syncs the data you are trying to retrieve in it.
j
like this ?
s
Check the link I posted above
j
I did, but that has SQL and I'm not familiar with it
s
Oh right, you will need a bit of SQL to make it work
j
Copy code
sql
create table public.developers (
  id uuid references auth.users not null,

  primary key (id)
);

alter table public.profiles enable row level security;
Should this be enough?
And how can I query the user data? Do I need to store everything in this new table or can I query stuff from
auth.users
?
s
No you will also need a trigger to add data to that table whenever a new user is created
j
But like
auth.users
already has the email
Do I need to create another email field in this new table to be able to access it?
What if I do this?
s
Please read my initial message as to why you can't access that table like this