https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Hi!
    d

    dbco0per

    09/21/2022, 2:47 PM
    I manually uploaded a csv to Supabase and I'm getting an error when I try to introspect the new table with Prisma "The following models were commented out as we could not retrieve columns for them". I have RLS turned off, and have successfully introspected other tables in the project with no issues.
    n
    • 2
    • 3
  • Anyone have any recommendations on how would you track whether a user has read a message or not?
    l

    lewisd

    09/21/2022, 4:03 PM
    I'm building a chat app and need to track which messages from various conversations the logged in user hasn't read yet. I've seen a few ways of doing this already online. 1. Check the last time the user was active, then check all the conversation messages that have been sent past that time and use this as a count to show unread messages. 2. I didn't fully understand what they meant with this one, but something along the lines of creating another table called
    read_user_messages
    and create a link to all the messages they've read? Please find my current db design attached
  • how does supabase work
    k

    kapsonfire

    09/21/2022, 4:56 PM
    Im' really interested in using supabase but need to know how it works like I have a REST API, a GraphQL? API. So going for REST the isomorphic client is gonna usa fetch/xmlhttprequest? Going for GraphQL is going to create a websocket? When using on backend, i use a service role which is permitted for every table/row/column. Am I able to execute directly SQL Statements via a native postgres client to reduce overhead? Realtime Subscriptions also work via Websocket?
    g
    • 2
    • 6
  • Cant delete more than 100 rows from supabase dashboard?
    l

    Lukas V

    09/21/2022, 5:24 PM
    I have 2 questions: I am trying to delete all selected rows from my table, but I get this error:
    Copy code
    Failed to run sql query: cannot truncate a table referenced in a foreign key constraint
    Another question is - how do I reset the row count back to 1?
    j
    g
    • 3
    • 3
  • How to extract logs from Supabase
    m

    mintavenger

    09/21/2022, 5:45 PM
    I am aware of the logging features from the UI (https://supabase.com/docs/guides/platform/logs) however, the Log Explorer is limited and I would like to use something like Datadog/Splunk/etc. to view, monitor, visualize the logs. Is there a way to pump logs to an external service?
    g
    • 2
    • 3
  • How to update data in view
    w

    wholelotta

    09/21/2022, 6:28 PM
    Hello, I have my table users with some fields that I don't want the user to see/update. So I created a view, but whenever im trying to update the view, I get error 400 and this is the error
    g
    s
    • 3
    • 93
  • Sorting composite query by array_position
    s

    Sand Kingston

    09/21/2022, 8:05 PM
    I'm making a Trello clone which allows task reordering. For that, I've chosen to use an array field in the Database for storing the task order. When selecting the tasks, I'm using
    ORDER BY array_position(task_order, task_id)
    , which works perfectly. How can I order like that when making a query in supabase? The query looks like this:
    Copy code
    await supabase.from('board')
        .select(`
          id,
          title,
          description,
          taskOrder: task_order,
          tasks(
            title,
            description
          )     
        `)
        .eq('id', id);
    g
    • 2
    • 3
  • Can I GET or POST an Image (or any file) to Storage via REST alone?
    a

    AtomsInTheVoid

    09/21/2022, 8:49 PM
    I have an image in storage and now I'd like to use REST to grab it. If I go to the image I can use the "Copy URL" button and it'll give me something like this:
    Copy code
    https://uvozsbejenxqdtse.supabase.co/storage/v1/object/sign/test/637977266224775676.jpg?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1cmwiOiJ0ZXN0LzYzNzk3NzI2NjIyNDc3NTY3Ni5qXQiOjE2NjM3OTI4ODAsImV4cCI6MTk3OTE1Mjg4MH0.u0gxH1s2wYNM_DZP_HGLx6TEOG5-1I1mY70PtUFHilk
    (altered slightly so it won't actually work for you). This actually works, I can GET from here and receive the image. But I need to lock it down so only auth users can grab this file. The weird thing, is the Token here isn't a JWT token, nor is it my apikey.. it's something else? Something that doesn't expire either because it can be two days later and the link will still work. a) what is this "token"? b) how do I lock it down so only people with the jwt token can GET/POST into the bucket? Maybe this isn't possible, which will be a shame because that'll be a dealbreaker and it's literally the last thing I need to get working...
    g
    • 2
    • 41
  • Triggers disable realtime?
    d

    DanMossa

    09/21/2022, 11:39 PM
    Hello all! I currently have a realtime table,
    messages
    , that my app subscribes to based on inserts. This has been working, it stops working once I have added a trigger to that table. Any ideas? When debugging I noticed that if I change the
    Enabled mode
    on my trigger to
    Origin
    , the trigger activates but realtime stops working. If I set it to
    Replica
    , realtime works but the trigger doesn't activate. Setting it to
    Always
    makes the trigger work, but not realtime. I also noticed that nothing is actually being inserted into the
    messages
    table when my trigger is set to
    Origin
    or
    Always
    . Which is why realtime isn't working, because there's nothing being inserted. Anyone know why inserts stopping working after Triggers are enabled?
    g
    u
    s
    • 4
    • 28
  • Phone number authentication
    o

    organicX

    09/22/2022, 1:50 AM
    Is there a pricing plan for Phone Authentication? Or is it all free for unlimited users? I didn't see anything specific about its pricing on supabase's pricing page.
    g
    • 2
    • 3
  • Getting 400 status when Loading file to storage bucket
    v

    ven

    09/22/2022, 2:24 AM
    but no error and a null data object. have attached the console shot. any help? i am following these docs - https://supabase.com/docs/reference/javascript/storage-from-upload
    g
    • 2
    • 32
  • Supabase NextJS Password Recovery
    p

    Prashant Singh

    09/22/2022, 5:09 AM
    Is there any good example of how to handle password recovery with NextJS?
  • Difference between realtime and supabase client
    m

    maglev

    09/22/2022, 6:28 AM
    Hi, does the standalone supabase/realtime package offer the same "listen to database" changes functionality as the supabase-js client? If so where can I find the REALTIME_URL for the database? I'm already using Prisma for database operations so not sure if I need to install the supabase client just to use the realtime listener features.
    m
    • 2
    • 3
  • Anyone explain why I'm getting this error in my logs?
    u

    49Ryann

    09/22/2022, 6:41 AM
    Was working fine but now all the logs just show me this, edge functions. Is there an issue currently with SB?
    • 1
    • 1
  • Restored project is empty
    b

    binajmen

    09/22/2022, 7:33 AM
    Hi, I restored a hobby project but the DB is empty, which should not be the case. Is the DB wipe out when a project is paused?
    n
    • 2
    • 2
  • Inserts not working
    c

    CANDY

    09/22/2022, 10:46 AM
    Whenever i try to submit a form to insert data, i receive this error:
    Copy code
    Object { message: "FetchError: NetworkError when attempting to fetch resource.", details: "", hint: "", code: "" }
  • Log explorer fails to load due to a 403 error
    y

    YelloJello

    09/22/2022, 11:31 AM
    When I attempt to view the API, Postgres or Realtime logs I get the following error. The log explorer results are the same. Is there a particular role that the user
    supabase_admin
    should have to view logs?
    Copy code
    js
    {
      "code": 403,
      "message": "Failed to get project's logs",
      "requestId": "45c2ebe6-5ee3-4589-91c0-99091cb145e9"
    }
  • RLS policies, how to bypass in some cases
    t

    tyakymiuk

    09/22/2022, 1:05 PM
    Hey! I'm new to Supabase, and just wondering how you're approaching one of the issues I faced. My client is talking directly to Supabase, I'm using RLS and policies to restrict fetching records that have the same user_id (just a column) as the currently authenticated user has. But now I'm struggling to understand how to get for example the count of records in the table (which should be accessible for everyone) when the policy is restricting me to see only matching with my id records. Or another example: is how to check if the username is unique across the table? first thing that comes in mind is to handle it via edge functions but maybe there's a common approach that you're using for this (utilizing policies or some other things)? Thanks in advance, I'm new to Supabase and SQL as well
    g
    k
    • 3
    • 13
  • Why did handleAuth disappear in Supabase Auth Helpers (next)
    t

    The Aleks

    09/22/2022, 1:13 PM
    I noticed that the current implementation of Supabase Auth Helpers for NextJS lacks the
    handleAuth
    function which creates the login/logout endpoint for cookie authentication. Why is that?
    d
    • 2
    • 2
  • How to use Twilio npm package in edge functions Deno
    u

    49Ryann

    09/22/2022, 1:58 PM
    I've been trying to use the twilio package in Deno for edge functions but having no luck, does anyone know how I'm able to get it to work? very limited knowledge on this online. https://www.npmjs.com/package/twilio
    d
    • 2
    • 2
  • Dependent Database Triggers & Functions
    d

    drewbie

    09/22/2022, 2:54 PM
    I have a database trigger that creates a user_shop for a user after a shop is created. Via the following trigger/function
    Copy code
    create trigger add_shop_user_from_shop
      after insert on public.shops
      for each row execute procedure public.add_user_shop_from_shop();
    
    create function public.add_user_shop_from_shop() 
    returns trigger 
    language plpgsql 
    security definer set search_path = public
    as $$
    begin
      insert into public.user_shops(user_id, shop_id, role)
      values (auth.uid(), new.id, 'ADMIN');
    
      return new;
    end;
    $$;
    Which all works fine and well. I've decided that I want to create a shop for a user when a user record is created. However, I can not able to get that trigger/function to work as the prior one is already migrated into the database. I am trying
    Copy code
    create trigger create_shop_from_user
      after insert on public.users
      for each row execute procedure public.create_shop_from_user();
    
    create function public.create_shop_from_user() 
    returns trigger 
    language plpgsql 
    security definer set search_path = public
    as $$
    begin
      insert into public.shops DEFAULT VALUES;
    
      return new;
    end;
    $$;
    But I am getting an error saving the user and its due to the association of the user_shop to the user. How do I create a shop from an inserted user in the new function while allowing the existing function that creates the user_shop association row to still run? Any help is appreciated!
    g
    • 2
    • 6
  • ECONNREFUSED from Amazon as I try to generate types through supabase CLI?
    m

    Migu

    09/22/2022, 3:13 PM
    Hey 👋 I'm currently experiencing every now and then as I try to
    supabase gen types typescript --db-url postgresql://etc etc
    ; the debug error message says "connect ECONNREFUSED 52.59.3.55:5432 and from the looks of it it's an Amazon IP address. Could I be timed out for security reasons, could Amazon encounter issues (I doubt somehow) or am I doing something wrong? It does work most of the time, it's just that sometimes it decides not to and block on that… Anyone else had this?
    d
    • 2
    • 2
  • How to get session from a SSR application?
    m

    Miguel Espinoza

    09/22/2022, 3:52 PM
    Maybe I'm missing something, but this feels like a bug. I have a Remix project and from the advice on Github, I created a SupabaseClient per route request by passing the users accessToken to
    global.headers
    With this configuration, unfortunately, I'm unable to get session or user. Is this expected? More details in the issue I reported: https://github.com/supabase/gotrue-js/issues/450 P.S. Too many auth issues with supabase... It's a bit concerning. Hopefully this is an oversight on my end
    g
    • 2
    • 4
  • How to get the active session synchronously in v2.x
    e

    enyo

    09/22/2022, 4:12 PM
    In the previous supabase-js versions you could call
    supabase.auth.session()
    and would get the current session immediately which is good, since it allows to update the UI directly. How can this be achieved in v2? The only thing I see is
    supabase.auth.getSession()
    and it's async.
    g
    • 2
    • 3
  • Recommended setup for API endpoints with additional logic
    d

    davitykale

    09/22/2022, 6:41 PM
    If I want my application to call endpoints that encapsulate a bit more logic than just database updates, is it okay to encapsulate that within Edge functions (aka update Supabase database + update a third-party-service in the same function)? Or should I make these two separate processes on the client? Or use an entirely different service (like Google Cloud Run) to encapsulate the two?
    c
    • 2
    • 2
  • Logging data from postgresql function using plv8
    t

    tyakymiuk

    09/22/2022, 9:06 PM
    Hey! I'm trying to understand how to debug values (print them so that they're visible in pg logs on the Supabase dashboard) going with the following function but I don't see anything here (see screenshot). Maybe you faced an issue like that and know how to print/log some data so that it's easy to debug values?
    Copy code
    create or replace function calc_plv8()
    returns setof user_profiles
    as
    $$
    const result = plv8.execute('SELECT * FROM user_profiles');
    plv8.elog(NOTICE, 'this', 'is', 'inline', 'code');
    plv8.elog(INFO, 'this', 'is', 'inline', 'code');
    plv8.elog(DEBUG5, 'this', 'is', 'inline', 'code');
    return result;
    $$
    language plv8
    SECURITY DEFINER;
    
    select * from calc_plv8()
    P.S. function itself is working and returning what's needed but with no logs
    g
    • 2
    • 2
  • Structure for Users who can group together as an Org?
    a

    AtomsInTheVoid

    09/22/2022, 10:39 PM
    So I'm staring at my Storage area and contemplating how to best structure this within the confines of Supabase policies etc. My end goal is to allow users to sign up as one person companies, or invite others to join their organization. If they're in a shared org, they'll be able to collaborate on projects and thus have access to the same objects being stored in certain folders. For example I could have:
    Copy code
    User123 \ CoolTechInc \ file a
    User456 \ CoolTechInc \ file b 
    User456 \ HotTechInc \ file c
    User789 \ OtherCompany \ file d
    User123 should be able to access file a & b, and User 456 file a & b & c, and User789 only file d My pathing scheme above might not be the smartest way so I'm wondering how it's done out there in the real world? I've used other webapps that allow this, such as Miro where you can go in alone, or invite others from your org to collaborate with you
    g
    • 2
    • 3
  • Unauthorized function invocation
    p

    Patryk Makowski

    09/22/2022, 11:35 PM
    Hi, I'd like to invoke my edge function without authorization of the user. I have very simple app that only need to invoke 1 edge function to send some data to the server. Can I do that?
    t
    • 2
    • 11
  • Array of jsonb .or() not working
    l

    lewisd

    09/23/2022, 8:27 AM
    This is my current JS query:
    Copy code
    let query = supabase.rpc("search_listings", {
            search_query: searchQuery,
          });
          if (conditions.length > 0) {
            const string = conditions.reduce((string, currentCondition, index) => {
              return (string += `lineItems->>condition.eq.${currentCondition}${
                index < conditions.length - 1 ? "," : ""
              }`);
            }, "");
            query = query.or(string);
          }
          const { data } = await query.limit(10);
    It's currently not working when a condition is selected. If I
    console.log
    the
    .or()
    string, I get:
    lineItems->>condition.eq.new
    • 1
    • 3
  • Append data in many-to-many relationship
    b

    bhark

    09/23/2022, 10:45 AM
    I have two tables:
    teams
    and
    members
    . These two are joined by a many-to-many table, which holds of course its own
    ID
    ,
    team_id
    and
    member_id
    , as a composite primary key. Team members can have varying privileges in their teams. They can have no privileges (received an invite), read-only (invited as a user) and read-write-delete (team manager). I can solve this by having three different join tables:
    project_invites
    ,
    project_members
    and
    project_admins
    . This seems lame. I'd like to be able to define their role directly in the join table, and be able to use this when writing RLS policies. Is this possible? - and if so, how do I go about it? Thanks (:
1...282930...230Latest