https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Does anybody have any guides, tips or material regarding social media notifications db design?
    l

    lewisd

    09/18/2022, 1:18 PM
    I've tried following this: https://tannguyenit95.medium.com/designing-a-notification-system-1da83ca971bc But its kinda frying my brain and it's raising more questions than its answering for me.
    m
    g
    • 3
    • 22
  • Stored user data after changing
    g

    Gabriel Feitosa

    09/18/2022, 5:01 PM
    what is the best way to store user data after it changes?
  • Upgrading supabase into v2 subscribe
    s

    saeros

    09/18/2022, 5:40 PM
    Hi, recently I upgraded my project into v2. On my local setup real-time subscription is just working fine. But in production supabase still response with old subscribe model. Should I somehow upgrade my supabase project into v2?
    g
    • 2
    • 4
  • Sveltekit Auth Helper update for latest sveltekit ?
    a

    ak4zh

    09/18/2022, 5:44 PM
    Is this package going to get updates to work with latest sveltekit? https://github.com/supabase/auth-helpers/tree/main/packages/sveltekit I have multiple projects I am unable to update to latest sveltekit as I was using the supabase auth helpers in them.
    d
    b
    • 3
    • 4
  • Create a new Table with a parameterized name
    s

    Sonny Vesali

    09/18/2022, 6:19 PM
    Hi everyone postgres noob here, I have a seemingly simple function that I want to take an input and create a table that takes in a parameter and then creates a table with the parameter name with an arbitrary schema.
    Copy code
    CREATE OR REPLACE FUNCTION add_token_table(token_name text)
    returns void as $$ 
    BEGIN
       execute format(
         'create table', token_name, '(hexBalance text)'
       );
    END
    $$ language plpgsql
    What am I missing here, also I haven't found anything that is terribly too helpful for writing these kinds of postgres functions so if anyone has any resources that help them write these sorts of functions easily, also feel free to drop those as well, Thanks
    g
    • 2
    • 2
  • Don't know what to do with access token and etc
    a

    AnimeDev

    09/18/2022, 6:30 PM
    Hello. I'm using Discord as provider for my authorization. After using is authorized through Discord, it redirects back to my page with access token and other data. What should I do with it?
    j
    • 2
    • 2
  • Use supabase database rls in the server folder of nuxt
    r

    Rexrider

    09/18/2022, 6:44 PM
    Hello, I use supabase in my project on nuxt 3. Everything works fine except when I activate the rls policies of the database. My insert code is in the server folder of nuxt so it doesn't know the user connected. How can I send it the user?
    g
    m
    • 3
    • 4
  • UI Team Member Access
    t

    thestepafter

    09/18/2022, 7:11 PM
    I have read through https://supabase.com/docs/guides/hosting/platform to better understand the permissions for team members on my Supabase account. Are there any plans for providing a role that only gives access to the API Docs? For security and data integrity reasons I am not comfortable giving my frontend developers full access to the code and SQL editor window in the UI.
    g
    • 2
    • 4
  • Failed to run sql query syntax error at or near end
    l

    lewisd

    09/18/2022, 8:05 PM
    Does anyone see what's wrong with my sql function?
    Copy code
    create function create_listing_liked_notification (receiver_id uuid, liker_id uuid, listing_id uuid)
    returns void
    language plpgsql
    as $$
    declare
      new_notification_id bigint;
    begin
      insert into notifications ("receiverId", "actorId")
      values (receiver_id, liker_id)
      returning id into new_notification_id;
      insert into listingNotifications("notificationType", "notificationId", "listingId")
      values (1, new_notification_id, listing_id)
    end;
    $$;
    g
    j
    • 3
    • 5
  • Failed to run sql query missing FROM-clause entry for table new
    p

    pvtctrlalt

    09/18/2022, 8:11 PM
    Hi, When trying to run this function i get the error in the title and im not sure where i am going wrong
    Copy code
    create or replace function createticket("auth" text, "ticketname" text, "issuetype" text, "devicetype" text ,"issuedetails" text, "priority" text)
    returns void
    language plpgsql
    security definer set search_path = public
    as $$
    BEGIN
      IF  (checkifauth(auth)) THEN
        insert into public.tickets (id, ticketname, issuetype, devicetype, issuedetails,priority)
         values (new.id,new.ticketname,new.issuetype,new.devicetype,new.issuedetails,new.priority);
      END IF;
      END;
    $$
    and this is my other function incase that has issues
    Copy code
    BEGIN
      IF EXISTS (select authkey from public.userprofile where authkey::text = auth) THEN
      return true;
      else return false;
      END IF;
      END;
    and this is thw query i run
    select createticket('0d06829a-d271-4dde-b69a-6d16a2254143','test','test','test','test','test');
    g
    • 2
    • 8
  • Issues getting data using vite
    j

    jxyz

    09/18/2022, 8:43 PM
    I'm using Vite in my project, check my example here
    • 1
    • 1
  • How do I aggregate multiple rows of a joined table in SQL?
    e

    edgaras

    09/18/2022, 10:15 PM
    I have query 2 tables: jobs and jobs_filters. The jobs_filters is a M-M table to reference between jobs and filters. It contains job_id and a filter_id. Currently when I query the tables I get back a lot of rows (many filters for each job). How do I aggregate filter_id into a list, so there would be only 1 row per a job?
    g
    t
    • 3
    • 2
  • RLS How to read using join on column value?
    d

    DanMossa

    09/18/2022, 10:33 PM
    Hello! I have two schemas,
    messages
    and
    rooms
    . This is the
    rooms
    schemas:
    Copy code
    CREATE TABLE rooms (
        id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        user_id_one uuid NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
        user_id_two uuid NOT NULL REFERENCES users(user_id) ON DELETE CASCADE
    );
    messages
    schema:
    Copy code
    CREATE TABLE messages (
        id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        from_user_id uuid NOT NULL REFERENCES users(user_id) ON DELETE CASCADE,
        message text NOT NULL,
        room_id integer NOT NULL REFERENCES rooms(id) ON DELETE CASCADE,
        create_time timestamp with time zone NOT NULL DEFAULT now(),
        message_id uuid NOT NULL UNIQUE
    );
    I want to create an RLS policy on the messages table for
    SELECT
    such that a user can only read messages for which they are either part of
    from_user_id
    to
    to_user_id
    . This is what I have
    Copy code
    SELECT m.room_id
     FROM messages m
              JOIN rooms r ON r.id = m.room_id
     WHERE user_id_one = '8dd172ba-7cfc-4c43-a427-601e505709f6'
        OR user_id_two = '8dd172ba-7cfc-4c43-a427-601e505709f6'
    But how can I use my RPC function to match up with the valid
    room_id
    Copy code
    CREATE FUNCTION get_rooms_with_user_id(p_user_id uuid)
    Basically, I want to check that the only messages a user is getting is one where they are in that room. Any ideas?
    m
    • 2
    • 27
  • What is cheaper to access JSON from, Storage, or the DB?
    c

    Cory

    09/18/2022, 11:39 PM
    If I need JSON data that can change sometimes - to be accessed by 500k+ people per month, would it be better to access it via the DB, or Storage?
    k
    g
    +2
    • 5
    • 39
  • inviteUserByEmail Service_Role_Key
    b

    BoogersLLC

    09/19/2022, 12:35 AM
    In the [Documentation](https://supabase.com/docs/reference/javascript/auth-api-inviteuserbyemail) --
    inviteUserByEmail
    mentions that it requires the
    service_role
    key. Based on the type definition, I don't understand how I would pass the service_role key to the function. Or maybe I'm misunderstanding how the service_role key is applied? Also, for context, this is inside an edge function. So I believe I should have access to
    SUPABASE_SERVICE_ROLE_KEY
    I just don't understand how to apply it.
    Copy code
    javascript
    const { data: user, error } = await supabaseClient.auth.api.inviteUserByEmail(
        email,
      );
    g
    • 2
    • 2
  • timestampz now or with timezone?
    j

    jt

    09/19/2022, 1:08 AM
    do you default to now or now with timezone? why? thanks!
    g
    • 2
    • 1
  • Email Confirmation - onAuthStateChange?
    k

    KickSquare

    09/19/2022, 3:59 AM
    I currently have a signup flow that looks something like the flowchart I attached. After users sign up with email, they get redirected to a temp page that just tells them to check their inbox for email confirmation. The problem is that the confirmation link from email is just a blank page (and I don't see an option to specify this either). Furthermore, there doesn't appear to be a way to listen for when the user's email is confirmed (in which case I could redirect them from the temp page). Am I missing or overcomplicating something?
    n
    h
    g
    • 4
    • 9
  • Upload to public storage - Invalid JWT
    a

    alx90

    09/19/2022, 9:27 AM
    Hey there I created a simple public bucket. When I trying to upload a file via:
    Copy code
    const { data, error } = await supabase.storage
        .from("mybucket")
        .upload("public/avatar1.png", req.body.file);
    Im getting this error response:
    Copy code
    {
      statusCode: '401',
      error: 'Invalid JWT',
      message: 'new row violates row-level security policy for table "objects"'
    }
    Im not set any policies. My policies are totally empty. [UPDATE]: I executed this SQL query:
    Copy code
    -- 1. Allow public access to any files in the "public" bucket
    create policy "Public Access"
    on storage.objects for select
    using ( bucket_id = 'mybucket' );
    Still the same error :/ Some ideas what to do ?
    t
    • 2
    • 2
  • Can anyone see why this left join isn't working?
    l

    lewisd

    09/19/2022, 10:22 AM
    Copy code
    select notifications.id, notifications.status, notifications."receiverId", notifications."notificationObjectId"
    from 
      notifications
    left join 
      "notificationObjects" on notifications."notificationObjectId" = "notificationObjects".id;
    • 1
    • 6
  • 'new row violates row-level security policy for table tickets
    p

    pvtctrlalt

    09/19/2022, 12:32 PM
    Hey i have rls setup with these three options it can only update or select if
    (uid() = id)
    and can only insert when authenticated. but when i send in an insert statement from my program i get
    Copy code
    code: '42501',
      details: null,
      hint: null,
      message: 'new row violates row-level security policy for table "tickets"'
    this was my function. the user is signed in
    Copy code
    export async function createTicket(ticketdata:any) {
      const { data, error } = await supabase
      .from('tickets')
      .insert([
        { devicetype: ticketdata.deviceType },
        { issuedetails:  ticketdata.issueDetails },
        { issuetype: ticketdata.issueType },
        { priority: ticketdata.priority },
        { ticketname:  ticketdata.ticketName },
      ], { returning: 'minimal' }, { upsert: true })
      if (error) console.error(error)
      else console.log(data)
    }
    n
    g
    • 3
    • 17
  • Restrict devs with dashboard access from dropping tables
    s

    Spoonz

    09/19/2022, 1:22 PM
    Is there a way to prevent users with dashboard and SQL editor access from performing destructive actions like dropping tables and deleting data? I was thinking of setting some RLS rules based on claims or roles but if someone has dashboard access they can just change these from the SQL editor.
  • Next JS Protected Routes
    b

    B3n

    09/19/2022, 1:47 PM
    I'm trying to protect routes using auth-helpers however when I login, supabase.auth.user() on the client side shows I'm logged in but I have to wait a few mins before I can access protected routes. I'm new to web dev but I think it might be something to do with the login not being processed on the server side? Any help would be much appreciated.
    n
    g
    • 3
    • 42
  • Best practice to microservices architecture with supabase?
    s

    Syniex

    09/19/2022, 4:31 PM
    Does anyone have a suggestion what is the best practice to work with Supabase in microservices architecture? Multiple self-hosted instances (air gapped network 😭 ) one for each service. How I am supposed to work with the Supabase client on the frontend side? create multiple clients?
  • Supabase JS RC 2 - Unable to get count of rows
    n

    Nin

    09/19/2022, 4:35 PM
    Unable to get exact count with option head: true Below code is executing but returns undefined; why?
    Copy code
    const { data: total } = await supabase
            .from("tasks")
            .select("id", { count: "exact", head: true });
          console.log(total);
    g
    • 2
    • 2
  • Upsert a specific row with API
    e

    enti

    09/19/2022, 4:37 PM
    I got a table with 2 unique columns (both can only contain unique datas) I want to upsert column_2 according to column_1 (updating column_2 if column_1 data already exists, inserting instead) My code actually looks like:
    Copy code
    js
    const { data, error } = await supabase
      .from('users')
      .upsert({ column_1: 'data1', column_2: 'data2' }, { onConflict: 'column_1' })
    So for now, if there's a conflict on column_1, the query does nothing. But I want to update column_2 for that specific existing column_1 conflict instead. The doc doesn't provide any detail. Do you know how I could provide this request though my supabase API call?
  • How to filter is not null
    p

    pocin

    09/19/2022, 4:41 PM
    is this the correct syntax?
    supabase.from().select().not('column', is, null)
    https://supabase.com/docs/reference/javascript/not
    m
    • 2
    • 1
  • Storage Egress
    s

    Sahil Singla

    09/19/2022, 5:11 PM
    We are currently using Supabase storage as a CDN in one of our projects. But kind of facing troubles dealing with the storage egress consumption. I see the default CacheControl for the assets is set to 1hour and a default value when user tries to upload from the Supabase dashboard, we tough we have changed it to a much higher value it does seem to help us with the storage egress. To add further the traffic is very minimal(a few hundred/day). I would really appreciate if someone can help me understand how we can optimise our egress utilisation. Also, is there a way we can update the default cache control for the assets which are currently in the storage and will be added in the future? Is there a way to define or restrict the usage of CDN url to only my product(domain)?
  • Streaming API with Authz Rules
    g

    garyaustin

    09/19/2022, 6:31 PM
    Realtime uses the table RLS select policy and must meet it to send insert or update events.
    a
    • 2
    • 2
  • azure login not working
    s

    SimonP

    09/19/2022, 6:05 PM
    Has anyone tried to add azure as a login provider? I am stuck on the following error in the authentication logs:
    Copy code
    {
      "component": "api",
      "error": "Unable to find email with Azure provider",
      "level": "error",
      "method": "GET",
      "msg": "500: Error getting user email from external provider",
      "path": "/callback",
      "referer": "",
      "remote_addr": "212.95.23.44",
      "time": "2022-09-14T11:33:53Z",
      "timestamp": "2022-09-14T11:33:52Z"
    }
    e
    a
    b
    • 4
    • 4
  • Creating Indexes
    a

    adek

    09/19/2022, 6:11 PM
    Hi! I want to create indexes to implement full text queries. The documentation helped me to create indexes for 2 columns with string values, but I would like to create indexes for 4 columns, but 2 of them are arrays. How I can handle this?
1...262728...230Latest