https://supabase.com/ logo
Join DiscordCommunities
Powered by
# sql
  • u

    user

    09/06/2021, 1:39 AM
    i've always used uuids for ids in general my end goal is to be able to say "a bucket has many columns", that's it
  • u

    user

    09/06/2021, 1:40 AM
    (column the object, not an SQL column 😆)
  • u

    user

    09/06/2021, 1:41 AM
    so if I want to query all of the columns for a bucket, I'd do like "get all of the columns where the column id is some specified bucket id"?
  • u

    user

    09/06/2021, 1:41 AM
    I guess I'm still working in a prisma mindset where I'd do it the other way around:
    someBucket.columnIds.map(id => getColumn(id))
  • s

    stibbs

    09/06/2021, 1:43 AM
    You'd query with something like
    Copy code
    javascript
    await supabase.from('columns').select('*').eq('bucket_id', id);
  • s

    stibbs

    09/06/2021, 1:43 AM
    again, i don't really understand what you are trying to achieve, but perhaps you could use row level security to lock it down (assuming buckets correspond to users?)... probably not though
  • u

    user

    09/06/2021, 5:23 PM
    yeah, that works. I was thinking that I had to set up some "official relation" but I suppose not
  • s

    SETY

    09/06/2021, 9:40 PM
    How come i cant see the RLS options (I know i can do them myself) on my supabase instance?
  • s

    SETY

    09/06/2021, 9:46 PM
    Nevermind, I was on the complete wrong page
  • s

    SETY

    09/06/2021, 9:59 PM
    how do i query from auth.users using supabase?
  • s

    SETY

    09/06/2021, 9:59 PM
    im trying to utilize the javascript api and its like it doesnt even see it
  • s

    SETY

    09/06/2021, 10:00 PM
    can it not see the auth schema?
  • s

    SETY

    09/06/2021, 10:26 PM
    is there a way to pump in a raw AQL query
  • s

    SETY

    09/06/2021, 10:26 PM
    SQL
  • b

    burggraf

    09/06/2021, 11:32 PM
    Correct, for security reasons, you can't access the
    auth
    schema from the client.
  • b

    burggraf

    09/06/2021, 11:33 PM
    You can create a
    view
    or a create a
    function
    to access
    auth.users
    and then call the function with
    .rpc()
    .
  • u

    user

    09/06/2021, 11:55 PM
    Is there a way to restrict fields a user can update in a policy? For example if I add a role field to a table I would like to not allow regular users to update their own roles.
  • s

    stibbs

    09/07/2021, 4:08 AM
    I would probably move that to a seperate table
  • s

    stibbs

    09/07/2021, 4:09 AM
    e.g.
    public.users
    table has a FK referencing
    public.roles
    table. Then you can lock down the roles table?
  • s

    stibbs

    09/07/2021, 4:17 AM
    I'm starting to learn these fancy stored procedures/psql functions and was hoping for some help. I've got the below table, and I want to insert a record in it within my function... this is what I've tried but the Supabase SQL editor gives an error
    syntax error at or near "returning"
    public.users
    Copy code
    sql
    CREATE TABLE users (
      id bigint generated by default as identity primary key,
      user_id uuid references auth.users,
    );
    function
    Copy code
    sql
    ...
    insert into public.users returning id into new_user_id;
    ...
    Right now, all I want it to do is create a record with an auto-generated PK and a user_id of null
  • j

    jason-lynx

    09/07/2021, 4:23 AM
    you have to specify the fields you're inserting
  • j

    jason-lynx

    09/07/2021, 4:23 AM
    and the values
  • j

    jason-lynx

    09/07/2021, 4:23 AM
    insert into public.users(id, ...) values(...
  • j

    jason-lynx

    09/07/2021, 4:27 AM
    btw why dont you use the id from
    auth.users
    directly?
  • s

    stibbs

    09/07/2021, 4:34 AM
    Even if it auto generates
    id
    I need to specify? What value do I pass?
    Copy code
    sql
    insert into public.users (id) values () returning id into new_user_id;
  • s

    stibbs

    09/07/2021, 4:35 AM
    I'm trying to set up a form submission that optionally creates a user, so have an intermediate users table
  • s

    stibbs

    09/07/2021, 4:39 AM
    Ok changing the insert to be:
    Copy code
    sql
    insert into public.users default values returning id into new_user_id;
    gets me past that error and onto a new one 🙂
  • s

    stibbs

    09/07/2021, 5:05 AM
    Using the auto-generated api for my newly created function results in below error: api
    Copy code
    ts
    let { data, error } = await supabase.rpc('new_job_post', {...})
    error
    Copy code
    ts
    {"hint":"To call a procedure, use CALL.","message":"public.new_job_post(...) is a procedure","code":"42809","details":null}
    Oh I think it needs to be a function rather than a procedure?
  • j

    jason-lynx

    09/07/2021, 5:56 AM
    yeah i think so
  • j

    jason-lynx

    09/07/2021, 5:56 AM
    CREATE FUNCTION
    syntax
1...141516...52Latest