https://supabase.com/ logo
Join Discord
Powered by
# off-topic
  • s

    SETY

    08/14/2021, 11:31 AM
    I appreciate it. My thought process is correct here though? I have never worked in this lack of backend, so I need to maintain data integrity at the postgres level?
  • f

    florian-lefebvre

    08/14/2021, 11:32 AM
    Yes it's the most secure
  • s

    SETY

    08/14/2021, 11:34 AM
    RLS is just an SQL statement? Neat. I thought it had limitations. Thank you
  • s

    SETY

    08/14/2021, 11:38 AM
    And I am down a rabbit hole of postgres
  • v

    Varun Sharma

    08/14/2021, 12:22 PM
    Hey! Just wanted to ask that const { data, error } = await supabase .from('articles') .select(
    Copy code
    id,
                        auth.users (
                            created_by
                        )
    ) .eq('is_archived', false);
  • v

    Varun Sharma

    08/14/2021, 12:23 PM
    the relation auth.users is not fetched, or simply users is not fetched there is an error
  • v

    Varun Sharma

    08/14/2021, 12:23 PM
    how do I reference auth.users?
  • s

    SETY

    08/14/2021, 1:26 PM
    Which key are you using to auth with supabase? The anon key wont let you pull from auth
  • u

    0xhjohnson

    08/14/2021, 1:28 PM
    you can't reference
    auth.users
    since it is in a different schema. the recommended fix is to have a separate table in the public schema that has a trigger setup https://supabase.io/docs/guides/auth/managing-user-data
    Copy code
    -- Inserts a row into public.profiles
    create or replace function handle_new_user() 
    returns trigger as $$
    begin
      insert into public.profiles (id)
      values (new.id);
      return new;
    end;
    $$ language plpgsql security definer;
    
    -- Trigger the function every time a user is created
    create trigger on_auth_user_created
      after insert on auth.users
      for each row execute procedure public.handle_new_user();
  • s

    SETY

    08/14/2021, 1:28 PM
    oh you cant even query auth with the other key? Learned something
  • u

    0xhjohnson

    08/14/2021, 1:31 PM
    I believe it works if your using the other key
  • s

    SETY

    08/14/2021, 1:32 PM
    Can you clarify what you mean by trigger? A postgres trigger? Nevermind i see it
  • u

    0xhjohnson

    08/14/2021, 1:33 PM
    yup a postgres trigger, I edited my original response
  • s

    SETY

    08/14/2021, 1:45 PM
    Ill be honest, when I first started toying with supabase, i thought it would only be good for toy projects, because I have always built my own backend to control data. I guess i never fully dove into the power a DBMS. I assume most of these functions running at the DBMS level are an order of magnitude faster than parsing the information on the backend through node.
  • u

    0xhjohnson

    08/14/2021, 3:08 PM
    yup they are a lot faster at the DBMS level than going through a backend API. separate node backend is still much easier to use if you have a lot of logic that needs to be done. syntax for plpgsql is not the easiest to work with
  • z

    Zenon

    08/14/2021, 7:30 PM
    Hey I'm creating an app in NextJS I want to listen to realtime DB using Supabase, I subscribed to all changes in the posts table as mentioned in the docs, but how do I get the data that has been modified?
  • j

    Jacob Paris 🇨🇦

    08/14/2021, 8:40 PM
    Has anyone tried any multitenant saas with supabase yet? Toying with ideas on how to set the user authentication up for that
  • l

    Link

    08/14/2021, 9:06 PM
    everytime the event fires it gives u a payload and it includes a new property
  • l

    Link

    08/14/2021, 9:06 PM
    called new
  • u

    user

    08/14/2021, 10:21 PM
    What is the best way to do an email/password signup with additional fields like person name/team name? I'm able to create the user but not able to update the users table (which itself was updated by a trigger). I wonder if there is a race condition due to which my update isn’t working… gonna try an upsert instead.
  • u

    user

    08/14/2021, 11:47 PM
    No luck.
  • a

    Adamo

    08/15/2021, 1:26 AM
    Does anyone here use lobste.rs and is willing to invite me?
  • a

    Adamo

    08/15/2021, 1:26 AM
    if you are, I'd really appreciate it.
  • d

    Deleted User

    08/15/2021, 1:37 AM
    Does anyone know why my reports for my database would be missing data?
  • r

    RB_Gaura

    08/15/2021, 2:43 AM
    there's a few ways to solve this. You can either filter out on the front end. Or you can just not let them see on the backend (you can also do both).
  • r

    RB_Gaura

    08/15/2021, 2:44 AM
    Method #1 - Backend: Enable Row Level Security (RLS) for your table, and then create a policy that only allows users to see items that have the same userid as them. (then on the frontend simply do ``await supabase.from('Your Table').select('*')``)
  • r

    RB_Gaura

    08/15/2021, 2:46 AM
    Method#2 - Frontend: Filter out on the frontend, there's a variety of filters that can be used to do this in different ways. l would use the ``eq`` filter. https://supabase.io/docs/reference/javascript/eq
    Copy code
    Javascript
    const { data, error } = await supabase
      .from('Your Table')
      .select('*')
      .eq('user-id', user.id)
  • r

    RB_Gaura

    08/15/2021, 2:48 AM
    Also does anyone know how to allow multiple base urls for auth? I'm thinking for development vs production. I'm going to need my base url to be localhost in dev but in production it would be something else.
  • r

    RB_Gaura

    08/15/2021, 2:48 AM
    I also may have a network IP during dev
  • r

    RB_Gaura

    08/15/2021, 2:48 AM
    there are also like preview urls before deploying to the main url
1...757677...392Latest