https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Migrating Firebase Functions to SupaBase Edge Function
    b

    burakovali

    04/28/2023, 7:30 AM
    Greetings, we are considering migrating a customer's app from Firebase to Supabase. But we couldn't find a tool to migrate functions. Is there any documentation or any tool about this?
  • Biggest companies using Supabase in prod?
    a

    aaa983898943943

    04/28/2023, 7:53 AM
    Hi! Interested in using Supabase for a (hopefully-one-day-large) startup. Are there examples of larger companies using it in prod? Thank you.
  • SQL Database Structure
    l

    LeDragunov

    04/28/2023, 8:21 AM
    I'm creating an app and currently planning and building the SQL database (tables/views/functions). I want to know the best practise to build my database. What I was thinking, is to have all my tables as private and only expose Views and functions publicly. Do you think it will work and better for security purposes?
    v
    • 2
    • 1
  • Realtime subscription with custom SQL filter
    m

    Mirik

    04/28/2023, 9:22 AM
    Hi, in this case i am doing all my filtrations in js side ( inside payload fn ) , i know that filter is not accepting multiple keys. Is it possible to do multiple filtering with custom sql and how ? i will be very thankful for the links.
    Copy code
    room = await supabase
                  .channel('messages')
                  .on(
                    'postgres_changes',
                    {
                      event: 'INSERT',
                      schema: 'public',
                      table: 'messages',
                      filter: user_id=eq.${user.id}
                    },
                    (payload) => {
                      console.log('sender');
                    }
                  )
                  .on(
                    'postgres_changes',
                    {
                      event: 'INSERT',
                      schema: 'public',
                      table: 'messages',
                      filter: user_receiver_id=eq.${user.id}
                    },
                    (payload) => {
                      console.log('receiver');
                    }
                  )
                  .subscribe();
    g
    • 2
    • 1
  • Fetching Data Type Error
    k

    karankartikeya07

    04/28/2023, 10:28 AM
    I have been setting up Supabase for my new projects, and it seems that there is some error fetching data in these new projects as Type error occurs. What can be done to solve this? Please guide. Thanks

    https://cdn.discordapp.com/attachments/1101454815814488084/1101454816011636797/supabase_error.png▾

    https://cdn.discordapp.com/attachments/1101454815814488084/1101454816301031424/supabase_eror_2.png▾

    • 1
    • 5
  • Looking for initial sign-in event listener
    j

    j3llybeans

    04/28/2023, 10:30 AM
    Is there any event/hook i can listen to when the user first signs in? I'm looking for some event where i can save the provider refresh and access tokens I've already tried
    Copy code
    ts
    supabaseClient.auth.onAuthStateChange((event, session) => {
      // either event.SIGNED_IN or event.INITIAL_SESSION
    })
    but they fired too often I'm only looking to save the tokens to an HTTP only cookie on that event, from there on, i'll handle the refreshing part. (this is for a spotify app)
    j
    • 2
    • 6
  • sort by relational data. SOLVED
    d

    DignifiedSwine

    04/28/2023, 12:47 PM
    Just looking to sort some data by the id of foreign data. Any idea how to do it?? I've tried: _supabase .from('exam<>student') .select('exam(*), score, studied, cheated, student(year)') .eq('student', sid) .order('exam(id)', { ascending: true })
    s
    • 2
    • 6
  • Supabase Edge Functions server not letting me change the folder structure
    v

    ven

    04/28/2023, 1:18 PM
    Hello, for better maintainability I was trying to nest my functions base on business logic but it wont let me. currently the only allowed folder structure is so -
    Copy code
    |- supabase
    |   |- functions
    |-  |-  |-_shared (shared .ts files)
    |   |-  |- <function-name>
        |   |-  |- index.ts
    |-  |-  |-import_map.json
    |-  .env.local
    |-  .env
    |-  .gitignore
    |-  config.toml
    |-  seed.sql
    is it possible to created business logic base nested folders inside of /supabase/functions ? tia
    s
    • 2
    • 24
  • Is there a way to tell supabase.js that an embedded document is not an array?
    e

    enyo

    04/28/2023, 1:42 PM
    When I use the JavaScript library to embed another table the embedded document is always type as
    OtherType | OtherType[]
    Is there a way to specify that the embedded document can only be a single row?

    https://cdn.discordapp.com/attachments/1101503594596925502/1101503594794074123/image.png▾

  • Supabase APp UI not working?
    l

    leoralon

    04/28/2023, 1:48 PM
    I'm just trying to log into the app on app.supabase.com and it won't load my projects. If I use the URL to get direct to a project I get a permissions error page. But I am the owner of the project so I'm not sure what else to do, been experiencing this since last night (almost 12 hours now) I've tried logging out and back in ~5 times now

    https://cdn.discordapp.com/attachments/1101505243646275675/1101505243893731368/image.png▾

    https://cdn.discordapp.com/attachments/1101505243646275675/1101505244250251314/image.png▾

    s
    a
    • 3
    • 4
  • Edge Functions Unit Testing
    f

    Flemx

    04/28/2023, 1:55 PM
    Hi, has anyone implemented unit tests within Edge Functions, could not find examples in the Supabase Documentation and I am getting some issues executing the function scripts due to incorrect env variables etc. And what testing libraries worked best, using the standard deno testing functions or an alternative? Also looking for the best way to mock the API / Database calls in Deno testing.
  • Access tokens scopes (per organization?)
    b

    benjamin_dobell

    04/28/2023, 2:20 PM
    Is there any way to obtain Supabase access tokens that are scoped to an organization? I have several clients and access tokens are used in CI (Github Actions). It's pretty easy to extract Github Action secrets. Ideally I'd be able to specify fine grained permissions for my access tokens, but I'd settle for being able to limit them to a Supabase organization. Is the only solution to create a new Supabase account per client (even if only used for access token generation)?
  • No function matches the given name and argument types. You might need to add explicit type casts
    l

    louis030195

    04/28/2023, 2:47 PM
    I used these functions https://github.com/burggraf/supabase-mailer/blob/main/Mail_Providers/Sendgrid.md Struggling to use my sql function in my trigger. I can use it directly though. it works, any idea? code: https://gist.github.com/louis030195/4d8ede553b6068f978bdd72ede6e5151
  • Local Edge function Debugger
    f

    Flemx

    04/28/2023, 3:19 PM
    Hi, does anyone if it is possible to inspect Local Edge function logs with ChromeTools, similar as how you would add --inspect to Deno? Or is there another workaround possible? https://deno.com/manual@v1.33.0/basics/debugging_your_code
  • Requests to storage fail due to missing storage.objects.version column
    n

    niklasd

    04/28/2023, 4:29 PM
    Hello! One of my four Supabase projects (one I have recently created) is missing the "version" column in my storage.objects table. As a consequence, all requests to storage fail with a 500 error. Has anybody else experienced that error?
    g
    • 2
    • 4
  • How to generate magic link when using rest api (gotrue)
    u

    0xAsimetriq

    04/28/2023, 4:33 PM
    I'm trying to generate magiclink via supabase's rest api, which I believe uses gotrue under the hood. As per documentation I found here: https://github.com/supabase/gotrue#post-admingenerate_link I am calling
    /admin/generate_link
    endpoint via fetch request below:
    Copy code
    const response = await fetch(`${this.#apiUrl}/admin/generate_link`, {
          headers: {
            apikey: this.#apiKey,
            Authorization: `Bearer ${this.#serviceRoleKey}`,
             'Content-Type': 'application/json'
          },
          method: 'POST',
          body: JSON.stringify({
            type: 'magiclink',
            redirect_to: 'https://mysite.app',
            email: 'myemail@gmail.com'
          })
        })
    But I am getting an error response with following data. Really not sure what is wrong, all those secret
    this.
    values are correct when logged.
    Copy code
    {
      "message": "no Route matched with those values"
    }
    • 1
    • 1
  • QueryCanceled (Statement timeout)
    g

    ghostlinkz

    04/28/2023, 5:37 PM
    I am on the free plan. Have been doing some data analysis using python and sql inside Jupyter notebook by connecting to my Supabase postgres database. As of last night I started getting the following errors when I run queries. Is my issue that im on the free plan or is there another reason why this started to occur?

    https://cdn.discordapp.com/attachments/1101562899132059668/1101562899278864414/supa-statement.jpg▾

    s
    • 2
    • 15
  • Is Auth-Helper a must have?
    s

    Sanctus

    04/28/2023, 6:21 PM
    Hello there, I'm building a project with some friends to learn the basics of Svelte/Sveltekit, Prisma and Supabase. We want to have some auth logic, but nothing convoluted. I have been trying to set up the project, but I'm encountering several problems with the auth-helper-sveltekit, and I am now wondering if it's really necessary.
    s
    j
    • 3
    • 19
  • "Or" query with many tables
    o

    osamita

    04/28/2023, 7:15 PM
    I have a users table and a people table. A person belongs belongs to a user. The foreign key in people tables is named "auth_id" I need to search a user filtering by the name, last_name (presents in people table) or by email (present in users table). I thought two solutions but neither works: First option: using an "Or()" function: let { data, error, count } = await supabase .from("users") .select(
    Copy code
    *,
              people:auth_id!inner(*)
    , { count: "exact", } ) .or("name.ilike.%ar%,last_name.ilike.%ur%,users.email.ilike.%aur%", { foreignTable: "people", }); this way, supabase responses: failed to parse logic tree ((name.ilike.%ar%,last_name.ilike.%ur%,users.email.ilike.%aur%)). Second option: adding other "or()" function under existent or() function, like this: .or("email.ilike.%aur%", { foreignTable: "people.system_users", }); but using the second "or()", supabase does not response with any item [], even though the firs or() could match.
    g
    • 2
    • 1
  • Distinguishing New Users from Existing Users for Phone Authentication and Onboarding
    j

    Jolly Joy

    04/28/2023, 7:52 PM
    Hey everyone! I'm currently working on implementing phone authentication in my app, and facing a challenge in determining whether a user is new or already exists in the auth.users table based on their phone number. My current approach is to run a RPC in the auth.users table, searching for the user's phone number. Depending on the result, I would either call the
    signUp
    or
    signInWithOtp
    method. Once I have identified the user's status (new or existing), I'd like to show different onboarding screens tailored to their experience. In short, is running an RPC in the auth.users table for the phone number an appropriate way to check if the user is new or existing? Appreciate any guidance or alternative suggestions on how to handle this situation.
    • 1
    • 1
  • Updating table in supabase dashboard is not working
    j

    joshh

    04/28/2023, 7:59 PM
    When I edit the data in my table rows, it reflects the change on the Supabase dashboard. However, when fetching in my app, it returns the old data from before. I've restarted my server, nothing seems to work. Help appreciated, thanks!
    s
    g
    • 3
    • 10
  • Security Definer trigger can not bypass another triggers security?
    v

    Vik

    04/28/2023, 8:15 PM
    I have a trigger that runs before updates on the profiles table to ensure some columns can not be changed:
    Copy code
    CREATE OR REPLACE FUNCTION prevent_profile_updates()
    RETURNS TRIGGER AS $$
    BEGIN
      IF NEW.profile_id != OLD.profile_id OR
         NEW.joined != OLD.joined OR
         NEW.follower_count != OLD.follower_count OR
         NEW.following_count != OLD.following_count OR
         NEW.post_count != OLD.post_count THEN
        RAISE EXCEPTION 'You are not allowed to update this column.';
      END IF;
    
      RETURN NEW;
    END;
    $$ LANGUAGE plpgsql;
    
    CREATE TRIGGER prevent_profile_updates_trigger
    BEFORE UPDATE ON profiles
    FOR EACH ROW
    EXECUTE FUNCTION prevent_profile_updates();
    I also have this trigger to update those columns +1 / - 1 whenever there are inserts or deletes. I created it as a SECURITY DEFINER but it seems even this can not bypass the previous trigger. What are my options?
    Copy code
    CREATE OR REPLACE FUNCTION update_profile_counts()
    RETURNS TRIGGER AS $$
    BEGIN
      IF TG_OP = 'INSERT' THEN
        UPDATE profiles SET follower_count = follower_count + 1 WHERE profile_id = NEW.user_id;
        UPDATE profiles SET following_count = following_count + 1 WHERE profile_id = NEW.followee_id;
      ELSIF TG_OP = 'DELETE' THEN
        UPDATE profiles SET follower_count = follower_count - 1 WHERE profile_id = OLD.user_id;
        UPDATE profiles SET following_count = following_count - 1 WHERE profile_id = OLD.followee_id;
      END IF;
    
      RETURN NULL;
    END;
    $$ LANGUAGE plpgsql SECURITY DEFINER;
    
    CREATE TRIGGER update_profile_counts_trigger
      AFTER INSERT OR DELETE ON relationships
      FOR EACH ROW
      EXECUTE FUNCTION update_profile_counts();
    g
    • 2
    • 4
  • pg_advisory_locks and P1002 errors on migrate+build with Prisma from Vercel
    g

    gwaiLoFi

    04/28/2023, 8:16 PM
    Hi, today we've started receiving a lot of P1002 errors from Supabase when migrating + building a NextJS 12 app with Prisma deployed thru Vercel, and just resolved a
    pg_advisory_lock
    that we believe was caused by a broken migration routine... maybe? Might be coming from pgbounce or something, but we have only just run into this issue today, long after setting up pgbouncer... Posting here in case there is something on the Supabase side or Postgres we should be aware of
    n
    • 2
    • 7
  • How to put more filters on stream
    b

    b.

    04/28/2023, 9:18 PM
    Currently it's capped at 1 filter, but I need to add more. Is there any way that we can bypass this?
    g
    • 2
    • 4
  • custom domain with supabase client & edge function
    a

    arthur5005

    04/28/2023, 9:19 PM
    Hi there. Supabase customer here. I understand edge functions don't work with custom domains, given the namespaced nature of the subdomains that functions live on, it's clear why, but I like having a custom domain for my oauth logins, and all other calls to supabase. That being said, I've noticed that setting a custom domain for initializing the supabase client (in a react native app) has the side effect of also trying to call edge functions against that domain, which clearly doesn't work. In order to use the client for edge function I've extended
    SupabaseClient
    class in typescript and overridden the
    functionsUrl
    property to point to the correct functions domain. Not the end of the world, but it's a bit verbose in typescript and was wondering: 1. Is there a better way to use a custom domain with a Supabase client instance along with functions? 2. Am I risking something silly extending the class like this? Thanks!
  • Supabase login not accepting token
    v

    ven

    04/28/2023, 10:18 PM
    I just upgraded my cli (1.52.2). I am trying to deploy some functions and i am not able to paste the token at the command prompt. I am stuck! 😦

    https://cdn.discordapp.com/attachments/1101633459501420685/1101633459648213022/supabase_login_not_accepting_token.png▾

    s
    b
    • 3
    • 4
  • Edge function errors out on call from client. works fine from Postman.
    v

    ven

    04/29/2023, 12:25 AM
    Have attached Deno docker error logs.

    https://cdn.discordapp.com/attachments/1101665489463287888/1101665489656234115/error_on_calling_the_edge_function_from_client.png▾

    g
    • 2
    • 2
  • Vector Dimensions Size, can we set any? Or does it have to be a specific size?
    s

    SunTzu

    04/29/2023, 1:16 AM
    Hi! I'm planning to use a table in supabase to store multiple embeddings that may vary of different embedding providers, whether thats cohere, openAI, something from huggingface etc. Is it possible to have in a table, the vector allowed to have any dimension size? Instead of specifying, or is it something that we have to specify? (And then have a table for each provider of embeddings)
    n
    • 2
    • 2
  • Delete RLS is not working
    b

    BoogersLLC

    04/29/2023, 2:07 AM
    Hey all, I have to be missing something but every attempt I make at debugging, everything seems fine to me. Additionally, I could of swore I've been using this same rule for weeks but I guess not. Here is my RLS on Delete
    Copy code
    sql
    (EXISTS ( SELECT 1
       FROM decks
      WHERE ((decks.id = notebook_users.notebook_id) AND (decks.user_id = auth.uid()))))
    Here is my service call
    Copy code
    notebook_users?notebook_id=eq.9c8f537d-2347-40ea-ad92-5866f04f0599&user_id=eq.090dca08-c31e-4fbb-8513-f96690c5263a
    This is my current users id
    Copy code
    7eefb80e-b6b1-4681-821c-b6fc713b3153
    Thus when I manually write the RLS rule into a select statement I get
    Copy code
    sql
    select * from notebook_users where notebook_id = '9c8f537d-2347-40ea-ad92-5866f04f0599' and user_id = '090dca08-c31e-4fbb-8513-f96690c5263a'
    and exists(select 1 from decks where id = '9c8f537d-2347-40ea-ad92-5866f04f0599' and user_id = '7eefb80e-b6b1-4681-821c-b6fc713b3153')
    Which returns the row I'm trying to delete. -- However, I get a 204 success response, and the row does not get deleted. - Also, I confirmed this is RLS, because if I disable RLS, I can remove the row. Any ideas? Or suggestions to further debug this?
    g
    • 2
    • 10
  • NextJS App Directory, Context, Stop Calls on Re-Render
    w

    wuxxy

    04/29/2023, 2:12 AM
    How do I stop making API calls when a user refocuses on the tab of the site. I've like memoized everything but im 90% sure the context is the main problem. I'm using the code in the docs for NextJS App directory
    Supabase Provider
    thing.
    n
    s
    h
    • 4
    • 6
1...195196197...230Latest