Querying through references

I think I'm in over my head.

I have a couple of different tables. The first is profiles, which has a fkey user_id referencing auth.users.id. The second is friends_table, which has two fkeys user_id and friend_id, both referencing column user_id in the profiles table, not auth.users. I've set up the RLS such that users can only see rows in which they are the user_id OR the friend_id, that way I'm not having to duplicate db entries for the sake of ease, however I'm having difficulty querying using the reference. Basically, if a user has a friend, or the friend is the user, I want to use the supabase js library to return the information for the corresponding entries in the profiles table.
Was this page helpful?