I have accounts with a user_id which is a foreign ...
# help
m
I have accounts with a user_id which is a foreign key to the users table. When i try to query accounts joined with users, it says no table users in the current schema. Do you guys know how i can fix it?
c
the users table is in the auth schema, so you probably need to use the fully qualified name - auth.users
m
First error:
But then, if i change to auth.users in my join i get:
Im using the client, like so:
c
I don't use the js client for queries, so I might be wrong here, but I think the parameter in parenthesis needs to be the column name in the target table - in your case auth.users (id)
actually, that's probably wrong...
m
The error does say that its the accounts.auth that doesn't exist tho
Some web ressources say its not possible to query the users table, and you should sync the desired data to a table in the public schema .
via triggers
c
you can definitely query it - you can either expose it through a view on the public schema OR you can implement the join in a view in a public schema.
I guess the question is can you do it ONLY via the JS client
...and I am afraid I don't know the answer to that question
m
ohh right
i forgot about views actually haha
i will go ahead and do that - thanks
s
You can't query anything in the
auth
schema when not using the
service_key
(this should only be used server side).