https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Storage Flow Question
    b

    brad

    12/19/2022, 3:07 PM
    Sorry i realise the first question is solved with the Storage Policies!
    g
    • 2
    • 17
  • Any way to access the access_token from session on server ? (Am using Sveltekit)
    d

    Devr

    12/19/2022, 4:08 PM
    I cannot actually access the users access token on server through getsession() , When I pass it through authorization header it responds That invalid JWT and cant parse it due to incomplete segments, please suggest a way so that I can fetch a user or use CRUD through API on server, Thanks
    g
    j
    a
    • 4
    • 9
  • How to change the statement_timeout with out super user?
    k

    KirioXX

    12/19/2022, 4:12 PM
    Hi, I tried to increase the statement_timeout on one of our environments, but since the postgres user is not a super user anymore I get this error:
    Copy code
    sh
    Failed to run sql query: "authenticated" is a reserved role, only superusers can modify it
    Is there another way to change the timeout that doesn't require a super user? Thanks!
    g
    • 2
    • 3
  • How do I query all entries in a profiles table using nextjs?
    r

    redwookie

    12/19/2022, 5:30 PM
    I have been trying to get this to work all day. Can someone point me in the right direction? Like explain it to me like I am 5 years old?
    b
    • 2
    • 2
  • Node.js API is used which is not supported in the Edge Runtime (Supabase-Auth-Helpers, Next13)
    r

    RaginKajan

    12/19/2022, 5:41 PM
    I created a new project following the Supabase auth helpers server components example. Once I add a middleware.tsx file to my project, I receive the following errors when trying to deploy to vercel (or when running npm run build). ./node_modules/@supabase/gotrue-js/dist/module/lib/helpers.js A Node.js API is used (Buffer at line: 90) which is not supported in the Edge Runtime. ./node_modules/@supabase/auth-helpers-shared/dist/index.mjs A Node.js API is used (Buffer at line: 215) which is not supported in the Edge Runtime. Is anyone else running into this issue?
    • 1
    • 5
  • SMS provider costs
    s

    Solias

    12/19/2022, 5:44 PM
    How do I drastically reduce my SMS provider costs? Currently using Twilio for Phone Auth, charging almost $0.05 to send one SMS to people in India. (That's quite absurd!) Any solutions on how I can figure this out, without having to move to Google Auth?
    l
    • 2
    • 5
  • noob question regarding fetching data
    v

    vexkiddy

    12/19/2022, 6:20 PM
    The below code is inside a
    +page.server.js
    file and gets called when the user visit's a particular url path eg.
    /explore
    (I'm using sveltekit v1 + supabase btw)
    Copy code
    import supabaseInit from '$lib/db'
    
    export async function load( event ) {
        console.log(event)
        const { data, error } = await supabaseInit
        .from('drops')
        .select(`
        *,
        collectibles (
            *
        )
        `)
        .order('id', { ascending: false })
        let drops = data;
        for(let i = 0; i < data.length; i++) {
            let profileData = await (await fetch(event.url.origin+'/profile/?value='+data[i].address)).json()
            drops[i].profileData = profileData
        }
        return {
            drops: drops
        };
    }
    This code goes off and gets a bunch of data from the drops table and returns it. However it blocks the page from rendering until its loaded all the data, including all the images. Some of the images are fairly large, however the browser doens't navigate away from the currently viewed page until all the data from supabase is loaded. Which in this cases takes a fairly long time. What am I doing wrong here ? Ideally i'd like to navigate to the page straight away and then a subset of the data gets loaded in. Either using lazy loading for the images or some kind of loading indicator. Could this be Sveltekit and not Supabase ?? Thanks in advance !
    b
    • 2
    • 5
  • Cannot subscribe to POSTGRES change via realtime
    w

    wasinwatt

    12/19/2022, 6:31 PM
    Hi, I did everything that the documentation says but my client cannot listen to postgres changes. As you can see in the attached image, it says invalid column for filter which is a supabase realtime log. I have no idea why that column is invalid and it's not working remotely because it works locally (supabase local development via supabase cli)
    g
    • 2
    • 13
  • Extra columns in join tables - is it possible?
    b

    bhark

    12/19/2022, 7:36 PM
    Say I have two tables,
    users
    and
    teams
    . These are coupled by a join table, with columns like this:
    id (primary key)
    user_id (primary key)
    team_id (primary key)
    I can then grab the users teams by doing something like this:
    Copy code
    .from('user')
    .select('teams!inner (*)')
    .eq('id', user.id)
    Now, let's say users can be assigned admin privileges per team. The user could be a member of several teams, but only have admin level privileges on one team. I'll call this column
    is_admin
    . The only reasonable place to store
    is_admin
    , as far as I'm aware, would be in the join table. My table would then look like this:
    id (primary key)
    user_id (primary key)
    team_id (primary key)
    is_admin
    \- but since I'm not querying the join table directly, I can't access the
    is_admin
    column. This seems to me like a trivial issue, but I can't seem to find any good solution. Maybe I'm searching on the wrong terms. Any pointers in the right direction is appreciated!
    g
    s
    • 3
    • 15
  • Could i to create a project with local docker instalation?
    h

    hermesalvesbr

    12/19/2022, 8:02 PM
    It already comes with one project, I would like to create others. Other projects with other databases. Is it possible locally, with docker-compose on my computer? I got to know the supabase recently and I'm practicing to get to know the structure better.
    g
    l
    s
    • 4
    • 8
  • Is there a puppeteer edge example that doesn't use an external service?
    k

    Kenji | Neon Crisis

    12/19/2022, 9:54 PM
    Would love to see an example of a puppeteer that doesn't use browserless
    u
    • 2
    • 3
  • How do i use presence in csharp?
    e

    Elfhild

    12/19/2022, 10:13 PM
    How do i use presence in csharp? is there any way using websocket?
  • Help with Postgres as a CRON Server
    w

    WalkerJson

    12/19/2022, 10:26 PM
    I hope someone is able to help as I am unable to find an example anywhere. I am looking to use pg-cron and http to send data to a slack end point. I have reviewed the blog post ( https://supabase.com/blog/postgres-as-a-cron-server) and I can see this must be possible as I would like to do similar to the below comment. "Sending welcome emails. If you use an email provider with an HTTP API, then you batch emails to that service. Write a function that selects all your signups yesterday, then sends them to your favorite transactional email service. Schedule it every day to run at midnight." Does anyone have an example where we query a table then send the results to an endpoint? Thanks in advance. Jason
    g
    • 2
    • 2
  • RLS possible for 'transactions'?
    v

    VWL Tobias Hassebrock

    12/19/2022, 11:35 PM
    Is it possible to design a secure database architecture based on postgres functions and RLS that works as like transactions? How would I do that? More specifically, I want to achieve: 1)Insert follower-following relationship 2)Increment follower counter 3)Increment following counter 4)Executing 1-3 from a function Can I gurantee that a) functions 1-3 can only be called from function 4? b) functions 2 and 3 are only executed if function 1 was executed successfully in function 4? c) function 1 can only be executed if the relationship combination did not exist before? PS: No, I do not want to count everytime I execute a select statement. The functions and tables could look like this: One table includes counters: user_id | follower | following uuid | int | int One table includes a follower-following relationship: relationship_id | follower | following uuid | uuid | uuid Function 1: create function insertFollowingFollowerRelationship(follower uuid, following uuid) returns void language plpgsql security definer as $$ BEGIN INSERT INTO "following_profile_system" (follower, following) VALUES (follower, following); END; $$; Function 2: create function decrementfollowing_counter(userId uuid) returns void language plpgsql security definer as $$ BEGIN update profiles_counters set "following_counter" = "following_counter" - 1 where id = userId; END; $$; Function 3: create function incrementfollowing_counter(userId uuid) returns void language plpgsql security definer as $$ BEGIN update profiles_counters set "following_counter" = "following_counter" + 1 where id = userId; END Function 4: create function followTransaction( followerId uuid, followingId uuid ) returns void language plpgsql security definer as $$ declare BEGIN -- Create new following & update counter PERFORM insertFollowingFollowerRelationship(followerId, followingId); PERFORM incrementfollower_counter(followingId); PERFORM incrementfollowing_counter(followerId); END; $$;
    g
    • 2
    • 8
  • filtering with multiple categories
    k

    kaori

    12/19/2022, 11:37 PM
    I was wondering if it’s possible to filter by categories? As in an item may belong to several categories. The user can choose between multiple checkboxes and filter through the data. They can select multiple checkboxes. So if the user chooses category A and B they will see all items that belong in those categories.
    g
    • 2
    • 1
  • How do I update a bucket path or upload if it doesn't already exist?
    v

    Vik

    12/20/2022, 12:00 AM
    Right now I'm working on replacing user avatars if they don't already exist. The one problem with this is that update will fail if the file path doesn't exist. I wish it was smart enough to upload it to that path. Is there a way to do this? I want to upload or update depending on if the file is there already.
    Copy code
    let { error } = await supabase.storage
            .from('avatars')
            .update('123456/avatar', formData);
    
          if (error) {
            console.log(error);
            return;
          }
    g
    • 2
    • 6
  • If you have a private storage bucket but want to get URLs for image saved into user profiles, how?
    v

    Vik

    12/20/2022, 1:32 AM
    So this is my current situation: I have a private avatars bucket that allows updating, deleting, or inserting if your auth.uid() matches the folder name. Select is open for all authenticated users because users should always be able to see other avatars. Right now when a user changes their avatar, I immediately request the publicURL and update the users profile with the new URL. This doesn't seem to work because even though the SELECT is open for authenticated users, the bucket is private so this doesn't work. I can create a signedURL but theres a time limit argument that's required. Is there an infinite option? Or am I missing something.
    Copy code
    if (!result.canceled) {
          const imageData = result.assets[0];
    
          const filePath = `${userId}/avatar`;
    
          const photo = {
            uri: imageData.uri,
            type: imageData.type,
            name: imageData.fileName,
          };
    
          const formData = new FormData();
          formData.append('file', photo);
    
          // Upload or replace existing users avatar
          let { error } = await supabase.storage
            .from('avatars')
            .upload(filePath, formData, {
              upsert: true,
            });
    
          if (error) {
            console.log(error);
            showErrorToast('Error', 'Something went wrong.');
            return;
          }
    
          // Get the URL from the storage bucket
          const { data: urlData } = await supabase.storage
            .from('avatars')
            .createSignedUrl(filePath, 99999999999999999999999999999);
    
          // Update the users public profile with the new avatar URL
          const { data: userData } = await supabase
            .from('profiles')
            .update({ avatar_url: urlData?.signedUrl })
            .eq('id', userId);
    
          return userData;
        }
    g
    • 2
    • 28
  • Best Practice on removing a user
    r

    rlightner

    12/20/2022, 1:39 AM
    If a user wants to be deleted what do people typically do to remove them programatically? Steps I think I should do: Query storage.objects for all rows with owner == user_id Call storage api via look removing all stored items Remove all rows that match user in tables Anyone else have a better plan/option?
  • Allow cors in specific domain supabase
    i

    izurugi

    12/20/2022, 1:52 AM
    Hello is there a way to allow only one origin in supabase? I'm trying to bypass cors issue in supabase. Trying to hide the supabase domain on verification. I think of fetching the verification url on my client but now getting cors issue.
    s
    • 2
    • 1
  • Temporary tables persisting between database function calls
    n

    nick-gorman

    12/20/2022, 4:12 AM
    I have a series of database functions that create temporary tables, but these seem to be persisting between function calls from the client. Shouldn't temporary tables get deleted when a session ends, is there a way to force this?
    s
    g
    • 3
    • 7
  • How to filter textarray[] ?
    v

    vikiyo

    12/20/2022, 5:23 AM
    Here is my code. But it's not working. I want to add multiple categories for a post. So I used an array for the category column. But cannot find a way to filter it. const { data: after_effects_templates } = await useAsyncData('after_effects_templates', async () => { const { data } = await client.from('after_effects_templates').select('title, description, tags, category[]').filter('category[]', 'in', "all")
    g
    • 2
    • 4
  • Realtime usage?
    c

    CheesyNeesh

    12/20/2022, 5:34 AM
    i'm also having trouble with getting realtime to work in the first place - i don't understand what the channels are for and don't really understand any of the sql queries in the docs
  • Is it possible to call realtime on rpc?
    e

    elliott

    12/20/2022, 5:38 AM
    Can I set up realtime updates on an rpc call?
  • Supabase RLS with sveltekit
    a

    Ape R Us

    12/20/2022, 7:00 AM
    Hi, How would i achive this when a user logs on. example: gofundme -I need the user to be able to create a fundraiser. -Everyone can view it once its live but -in the dashboard, only the user can view a list of their own fundraisers so they can edit etc, im assuming that, when fetching data from the dashboard i would do something like. supabase.from('fundraiser').select(*).match(event.locals.session.user.id) or supabase.from('fundraiser').select(*).eq('user_id' , event.locals.session.user.id) am i on the right track or is there a way to achive this with RLS?
    s
    z
    g
    • 4
    • 25
  • Using PGROONGA with a JSONB column
    i

    InASunshineState

    12/20/2022, 7:36 AM
    My JSONB column is just a one-dimensional array of words or phrases for elements, like tags, e.g.
    ["blue", "red", "dark purple"]
    I can get it to match individual tags great. And I mean GREAT. Blazing fast. Nine (single digit 9) millisecond returns across oodles of rows. But I'd really like to use the similarity searches of that same column. Similarity seems to be for pure text columns, but for the life of me I can't seem to get a solution; if I try solutions to cast the column when indexing my plan usually involves something that's a set-returning function (like jsonb_array_elements_text ) or it rejects it if it sees something like "mycolumn->>" or "mycolumn::text"
    SELECT tags FROM images WHERE jsonb_array_length(tags) > 0 and tags &@* '["compelte"]
    Failed to run sql query: operator does not exist: jsonb &@* unknown
    And then if I ever get semi-successful, like trying to break apart the array into independent rows for evaluations:
    Failed to run sql query: pgroonga: [similar][text] similar search available only in index scan
    Regardless of where or not I have used
    SET enable_seqscan = off;
    Any good leads I can follow?
  • Postgres Procedure RPC with JS API
    a

    AliCodes!

    12/20/2022, 8:59 AM
    I created the procedure below with the web console:
    Copy code
    sql
    CREATE PROCEDURE transact(id TEXT, created_at timestamptz, til TEXT, fra TEXT, beskrivelse TEXT, value float8)
    LANGUAGE SQL
    AS $BODY$
    INSERT INTO transaktioner VALUES (id, created_at, til, fra, beskrivelse, value);
    UPDATE kunder SET saldo = kunder.saldo - value WHERE id = fra;
    UPDATE kunder SET saldo = kunder.saldo + value WHERE id = til;
    $BODY$;
    ```but when I try to call it with the SB JS API: ```ts
    interface Transaktion {
        id: string,
        created_at: string,
        fra: string,
        til: string,
        value: number,
        beskrivelse?: string,
    }
    const transaktionKomplet: Transaktion = generateTransactionSomehow():
    console.log(await supabase.rpc("transact", transaktionKomplet));
    , it throws the error: ```json { error: { code: 'PGRST202', details: null, hint: 'If a new function was created in the database with this name and parameters, try reloading the schema cache.', message: 'Could not find the public.transact(beskrivelse, created_at, fra, id, til, value) function or the public.transact function with a single unnamed json or jsonb parameter in the schema cache' }, data: null, count: null, status: 404, statusText: 'Not Found' } ```Am I missing something about how RPCs work?
    s
    • 2
    • 21
  • How are the client libraries supposed to be imported?
    b

    bent

    12/20/2022, 9:04 AM
    I used to do this
    Copy code
    ts
    import { createClient, SupabaseClient } from "@supabase/supabase-js";
    import { PostgrestFilterBuilder } from "@supabase/postgrest-js";
    but after updating SvelteKit and Vite it now results in this:
    Copy code
    import { PostgrestFilterBuilder } from "@supabase/postgrest-js";
             ^^^^^^^^^^^^^^^^^^^^^^
    SyntaxError: Named export 'PostgrestFilterBuilder' not found. The requested module '@supabase/postgrest-js' is a CommonJS module, which may not support all module.exports as named exports.
    CommonJS modules can always be imported via the default export, for example using:
    
    import pkg from '@supabase/postgrest-js';
    const { PostgrestFilterBuilder } = pkg;
    And if I comply it claims that there are no default exports :/ I recall always having warnings related to something in that direction, but I could always just ignore them and it would work.
    s
    g
    • 3
    • 6
  • Keycloak configuartion
    n

    nidhin

    12/20/2022, 9:26 AM
    Hi Anyone please share any documentation to configure the supabase for keycloak.
    a
    g
    • 3
    • 2
  • Ghost record shows in UI
    j

    Jim

    12/20/2022, 9:50 AM
    Last night I tried clearing a table from the UI and when I hit refresh one single record kept coming back no matter what I do. If I made changes to any properties they reverted. Using the JS API it's no longer there. If I duplicate a table it's no longer there. I've cleared my browser cache but it still shows in the UI. Any ideas?
    • 1
    • 1
  • Passing and Receiving additional data on Sign-Up
    s

    SM0RT

    12/20/2022, 10:20 AM
    I'm signing a user up in my Dart/Flutter app like so:
    Copy code
    dart
     /// Sign up action that will be performed on
     /// click to action button in sign up mode.
      Future<String?> onSignup(SignUpData signupData) async {
        try {
          await supabase.auth.signUp(
            email: signupData.email,
            password: signupData.password,
            data: {'username': signupData.name, 'language': signupData.language},
            emailRedirectTo: 'myRedirectUrl',
          );
    
          context.showSnackBar(
            message: 'Please check your inbox for confirmation email.',
          );
        } on AuthException catch (error) {
          ...
        } catch (error) {
          ...
        }
        return null;
      }
    As you can see, I pass additional data for username and language. How can I access this data in Supabase and save it into one of my tables?
    s
    • 2
    • 4
1...737475...230Latest