https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Supabase Bucket's File Manager is Open Source?
    e

    Enon | USB

    02/11/2023, 8:18 AM
    Hello, I am building an app using Supabase itself, and we require to have a File Manager as well for our customers exactly like how Supabase has it. Is it open source so we can utilise it as well? Thank you.
    g
    • 2
    • 1
  • is there a way to use Unicode categories in regular expressions?
    e

    enyo

    02/11/2023, 8:53 AM
    Unicode categories allow to select a letter for example with
    \p{L}
    https://www.regular-expressions.info/unicode.html#category This seems to not be supported by postgres. I tried using it in a plv8 function instead but it also fails. (I assume that it's an older v8 version?) Any tips?
    • 1
    • 1
  • Infinite Scroll / .range()
    j

    jinsley8

    02/11/2023, 9:12 AM
    I'm trying to get pagination to work but the second round of fetching is returning an empty array. Here is my pagination helper:
    Copy code
    js
    function getPagination(page: number, size: number) {
        const limit = size ? +size : 24;
        const from = page ? page * limit : 0;
        const to = page ? from + size - 1 : size - 1;
    
        return { from, to };
    }
    Now my API route gets the new page number and size is set to 12. I have almost 60 items total in the database so I should get up to 5 pages.
    Copy code
    js
    const { from: fromIndex, to: toIndex } = getPagination(Number(page), Number(size));
    
    const { data, error } = await supabase
      .from('items')
      .select('*')
      .order('created_at', { ascending: false })
      .range(Number(fromIndex), Number(toIndex));
    On page load it loads the first 12 and is receiving
    page: 0, size: 12
    and returning 12 items. The next page load it get
    page: 2, size: 12
    and returning 0 items.
    fromIndex = 24, toIndex = 35
    . So it seems like it's skipping page 1 but should still be returning data but I only get an empty area after the initial page load.
    g
    • 2
    • 8
  • Flattening nested query
    a

    avalanche

    02/11/2023, 9:48 AM
    I have tables favourite (id, itemId) and item (id, someField1, someFiled1, ....) and I want to query favourite table and get out following (favourite_id, item_id) how can I do that? Following code will return item as nested object and I don't want that, I want to flatten the response and get only itemId as string.
    Copy code
    dart
      return supabase.client 
            .from('favourite')
            .select('id,item(id)')
    g
    • 2
    • 2
  • In what situations would you want to use getUser over getSession?
    x

    Xenni

    02/11/2023, 11:25 AM
    After doing some performance investigations I realised that my app was slow due to calls to
    getUser()
    which actually hits the
    /user
    endpoint to retrieve an up to date profile. This was a little ambiguous in the docs and makes me wonder in which circumstances you would typically want it over
    getSession().data.session.user
    . Obviously if you're updating a user profile that could be relevant although theoretically their session would refresh relatively frequently and thus make it more of a non-issue. If the user is executing the update themselves rather than say an admin then we would simply call
    refreshSession
    upon submission of the form too. If this is something we want to improve I'd be happy to update the docs for
    getUser
    to make the behaviour a little more explicit.
    j
    g
    • 3
    • 8
  • I need to store an array of json objects
    h

    Hugos

    02/11/2023, 11:49 AM
    I need to store this object in an array like this:
    Copy code
    json
    [
        { 
          "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", 
          "from": null, 
          "to": null 
        },
        { 
          "fen": "rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq d3 0 1", 
          "from": "e2", 
          "to": "e4" 
        }
    ]
    Since an array is already defined with ``{}`` how can i mark this as an array? just surrounding it with an extra set of brackets does not seem to work
    • 1
    • 1
  • grant bypass RLS to a specific role
    a

    Alaanor

    02/11/2023, 1:05 PM
    I can't find the query to do so.
    • 1
    • 2
  • Help with Realtime joins..
    a

    A-PRYME

    02/11/2023, 1:11 PM
    Say I have three tables,
    Post
    ,
    Comment
    and
    User
    . A post has a list of comments, and each comment belongs to a single user. How might I get a list of comments with their associated users as a stream? Say I want to build a reactive comment section where each comment is displayed together with the name and avatar of the user who wrote it. If a new comment is
    added
    ,
    liked
    or
    removed
    , the comment section should react accordingly. I ask this because Supabase allow realtime queries for a single table only. This means I can't easily join my comment table with my user table.
    g
    • 2
    • 4
  • The nextJS quickstart code isn’t typescript friendly and preventing me from deploying my site l
    j

    Jordy

    02/11/2023, 1:28 PM
    I made a site using supabase and I used the quickStart code at https://supabase.com/docs/guides/getting-started/quickstarts/nextjs so i could pre-fetch info but the code isn’t type friendly. It keeps saying binding element implicitly has an ‘any’ type
    s
    • 2
    • 1
  • SupabaseJS Join Tables / Queries
    m

    mjs

    02/11/2023, 2:56 PM
    Hi there, I have a "companies" table, a new company is created by a user and given a name, their "user_id" is also attached. When they first create a company, they're added to the "company_admins" table as an Admin of that company ("company_id" and "user_id" are referenced here). An Admin can send invites to other users and create a new "member_invitation" row in that table. When accepted, the row is updated so the "status" is now "accepted', and the a new row is created is the "company_members" table for that user. So, I now have a companies table, company_admins and company_members. When a user is logged in, irrespective of their role (or what table they are in), I want to show that company info. I've been looking at joins, but am coming across a lot of outdated code. As per the docs, I don't quite see something this complex listed in querying or fetching data. If anyone could help with how this pertains to the SupabaseJS methods, it would be greatly appreciated Thanks
  • config.toml postgres extensions
    n

    n10000k

    02/11/2023, 4:55 PM
    How can we enable a postgres extension by default in the config.toml for local dev? We want to enable a extension so a developer can pull the code base and it will be enabled by default via supabase start cli command.
    • 1
    • 2
  • Signing up twice in same session will break the server
    j

    jfbn

    02/11/2023, 5:08 PM
    I am using the
    auth.signUp
    method to create a user. Then I create another user shortly after, without logging into the first one. Server throws the error:
    Copy code
    Cannot use `cookies.set(...)` after the response has been generated
    I'm not entirely sure what's happening here. Is the
    signUp
    function setting cookies in the assumption that the user is meant to be logged in right away?
    g
    • 2
    • 6
  • Type Cast with TypeScript
    j

    Jarvis

    02/11/2023, 5:28 PM
    Hello, everyone! I'm trying to get the reviews the current user has uploaded with this TypeScript code: const { data, error } = await supabase .from('reviews') .select() .eq('reviewer_id', user.id); I'm getting this error: {code: '42883', details: null, hint: 'No operator matches the given name and argument types. You might need to add explicit type casts.', message: 'operator does not exist: uuid = text'} which seems totally correct to me. I'm giving the ID as a string, but it's uuid type in the DB. How do I "explicitly type cast" the UUID string as uuid type when using .eq()? My handle_new_user function casts birthday as date type: (new.raw_user_meta_data->>'birthday'::text)::date, but I can't seem to find how to do this with .eq(). I have found answers suggesting using the API to get my DB schema, but this seems like such a straight forward and common question. I feel like I must be missing something super basic, but I just haven't found how to do it yet. Thanks in advance for any help!
    c
    g
    • 3
    • 45
  • RLS Insert Authenticated users only returns 401
    s

    Shelby

    02/11/2023, 5:45 PM
    I have attached images... My process is when a user signs up, It goes a api request to my nextjs backend and use createUser() then after immediately I fire signInWithPassword() Then redirect my user to this form, but it keeps returning this error?
    g
    c
    • 3
    • 5
  • Is there a way to do supabase db remote reset?
    a

    avalanche

    02/11/2023, 7:59 PM
    This functionality is available for local database, but I can't seem to find a way to do it on remote.
    g
    • 2
    • 2
  • Return items that contains part of the string
    m

    Marius.Dmn

    02/11/2023, 8:02 PM
    Hello, is it possible to use textSearch() and get results that only contains the searched string? I tried something like this:
    Copy code
    .textSearch("ticker", `%${searchValue}%`, { type: "phrase" })
    But it dosen't seem to work. I'm looking for something like -> Search for joh and return Johnnatan
    g
    s
    a
    • 4
    • 18
  • Can you save data to the session object?
    n

    nish

    02/11/2023, 8:56 PM
    Maybe I am missing something obvious. Is there a way to save custom data to the session variable? The closest thing I can find is using
    supabase.auth.updateUser
    to save data to
    user.user_metadata
    , but this would save the information the database. How can I save information to the current session? I am using Supabase with Sveltekit and the Sveltekit-auth if that helps.
    g
    j
    • 3
    • 4
  • How can I change the response message after signing up with @supabase/auth-ui-react ?
    a

    Ailer

    02/11/2023, 9:12 PM
    Hi there! I've been able to customize a lot of messages of the "Auth" component imported from @supabase/auth-ui-react by defining the "variables" field in "localization" field in "Auth", but I couldn't find one for the message the user receives after pressing the sign up. How can I change it? The website I'm making is in portuguese, so I need to translate everything. Thanks!
    g
    t
    • 3
    • 4
  • Realtime not working locally
    m

    Mike!

    02/11/2023, 9:12 PM
    Post title a bit deceptive because I haven't tested in prod either, but trying to get things working locally and it's not taking Details and screenshots in the post thread
    k
    g
    +2
    • 5
    • 83
  • Supabase Dashboard not loading on Brave
    r

    robertn702

    02/11/2023, 9:34 PM
    The Supabase web dashboard stopped working for me today on Brave. I've done a hard refresh, cleared local storage, cookies, etc. re-authenticated and still run into an indefinite loading screen. I switched to Chrome and everything works as expected. Brave version:
    1.48.158 Chromium: 110.0.5481.77 (Official Build) (arm64)
    Running on:
    macOS Version 13.1 (Build 22C65)
    NEXT_DATA buildId:
    Jj7sGp495Wuv0AhUMjHgF
  • Service not healthy
    s

    Sarcodo

    02/11/2023, 9:53 PM
    I'm following this guide: https://supabase.com/docs/guides/cli/local-development trying to setup a db locally however I'm getting an error when running the
    supabase start
    command, I'm using npm so the command I run specifically is
    npx supabase start
    and I get the error shown in the image Sorry if this is a vague question, not sure where to go from here as I can't see anything online for this
    o
    • 2
    • 2
  • Does Supabase have session-based auth?
    p

    PeterP

    02/11/2023, 11:36 PM
    I'm not super clear on if that's the case. I just see mention of JWT, but I'm not sure if it's because that's the only one there is or because it's the most popular one so session-based auth is ignored
    g
    • 2
    • 2
  • Database error when logging in with discord followed by github but not inverse
    b

    Bloxs

    02/11/2023, 11:49 PM
    I'm trying to develop a site that has multi factor login and for some reason if your first time logging in is with discord then you just get a 500 error when trying to log in with github and in the logs it says
    failed to close prepared statement: ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02): ERROR: duplicate key value violates unique constraint "users_email_partial_key" (SQLSTATE 23505)
    but if I do it the other way around (log in with github first then discord) it works just fine. All auth related triggers are disabled.
  • trigger erroring with pg_cron
    n

    n10000k

    02/11/2023, 11:53 PM
    Copy code
    sql
    create or replace function public.update_balance() 
        returns trigger 
        language plpgsql 
        security definer 
    as $$
    begin
        select
          cron.schedule(
            new.id,
            '* * * * *',
            $$
                select status from http_post(
                  'https://webhook.site/redacted',
                  '{"customer": "1"}',
                  'application/json'
                )
            $$
        );
    
        return new;
    end;
    $$;
    returns:
    Copy code
    syntax error at or near "select"
    Any ideas? thanks in advance
    • 1
    • 1
  • Can someone explain why I have 8 auth requests, but only used 1 email to sign up using a magic link
    g

    garyaustin

    02/12/2023, 12:59 AM
    You can take a look at the API Edge logs in the dashboard for auth requests. Every request from a browser is actually 2 because of COR's preflight and then your call to sign in, you magiclink redirect, your signin token refresh/check, your getSession(?) so 8 right there. Depending on what you are doing.
    z
    • 2
    • 12
  • Does Supabase have a use case for two separate roles for authentication?
    z

    zhay

    02/12/2023, 1:20 AM
    I don't mean Admin vs Member view. This is more like two different sign in's and overall views of the app based on their role. Like a company vs job-seeker view for example
    p
    g
    • 3
    • 6
  • Update & Delete Row Items
    e

    Elbyssal

    02/12/2023, 1:22 AM
    Hello, I'm trying to update and delete "topics" but i'm not able to and I'm not getting any error. -- I am able to add topics, however. (Sorry if the resolution is obvious, I'm a beginner dev). I basically tried to copy the pattern from my addTopic for the other two but it didn't work.
    Copy code
    const createForumStore = () => {
        const store = writable([]);
    
    [...]
    
    const addTopic = async (topic) => {
            try {
                store.update((topics) => [...topics, topic]);
                await supabase.from('topics').insert({
                    title: topic.title
                });
                console.log('addTopic', topic);
            } catch (error) {
                console.error(error);
            }
        };
    
        const removeTopic = async (topicId) => {
            try {
                store.update((topics) => topics.filter((t) => t.id !== topicId));
                
                await supabase.from('topics').delete().eq('id', topicId);
                console.log('removeTopic', topicId);
            } catch (error) {
                console.error(error);
            }
    
        };
    
        const updateTopic = async (topic) => {
            try {
                store.update((topics) => {
                    const index = topics.findIndex((t) => t.id === topic.id);
                    console.log(topics)
                    return [...topics.slice(0, index), topic, ...topics.slice(index + 1)];
                });
    
    
                await supabase.from('topics').update(topic).eq('id', topic.id);
                console.log('updateTopic', topic);
            } catch (error) {
                console.error(error);
            }
        };
    It seems successful, returning an object with the correct id I see in supabase:
    Copy code
    {id: 21, created_at: '2023-02-11T23:02:34.341067+00:00', title: 'updatedTopic', description: null, tags: null, …}
    g
    • 2
    • 2
  • If you don't pass the service_role key to createServerSupabaseClient, is it basically the same as...
    d

    DYELbrah

    02/12/2023, 1:41 AM
    Would it basically be the same as createBrowserSupabaseClient? I don't see the difference. I won't be using service_role anywhere in my application not even in the server. For this reason, I don't see the difference at all.
    g
    • 2
    • 9
  • User role system
    l

    Le0n

    02/12/2023, 3:30 AM
    I want to create some kind of user role system, so only a user with a certain role can do some things others can't. What is the best way to do that? Im authenticating my users with Discord
    g
    • 2
    • 1
  • Enable Webhooks in Local Development
    i

    IstoraMandiri

    02/12/2023, 5:20 AM
    I noticed that support for webhooks for self-hosted was recently merged https://github.com/supabase/supabase/issues/10319#issuecomment-1415185175 Is there a way to enable this for local development? The webhooks menu item is not appearing in the studio UI when I use the latest version of the CLI.
    v
    s
    • 3
    • 4
1...128129130...230Latest