https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • With supabase studio open-sourced as well, is there anything which is still closed-source?
    a

    Alessio ๐Ÿฃ

    08/23/2022, 6:39 PM
    So anything which can only be found at/purchased from https://supabase.com/pricing and not self-hosted?
  • IP Addresses of Edge Functions
    j

    JackTheCoder

    08/23/2022, 6:40 PM
    So I need to use an API that will only allow me to access it from either a single static address or an IP range. Are the Edge Functions' IP addresses completely random around the world?
    o
    • 2
    • 1
  • order by does not work in a function
    r

    Relisora

    08/23/2022, 7:02 PM
    Hi! I have noticed a very weird behaviour for my SQL function. My goal is to send the
    ORDER BY
    table in the params, aswell as if it's
    ASC
    or
    DESC
    . Overall I found a solution that works pretty well... Except for one special case. Here is my function (please bear with me, I simplified as much as I could...):
    Copy code
    sql
    create or replace function test(order_input text default 'wizard_battles', order_direction_input text default 'asc')
    returns table (wizard_id int, wizard_battles bigint, wizard_wins bigint, wizard_win_rate numeric)
    language plpgsql
    as $$
    begin
    return query
    SELECT
        wizard_battles.wizard_id,
        wizard_battles.wizard_battles,
        wizard_battles.wizard_wins,
        round(100 - (wizard_battles.wizard_wins::real / wizard_battles.wizard_battles::real * 100::real)::numeric, 2) AS wizard_win_rate
        FROM ( SELECT team.wizard_id,
                count(*) AS wizard_battles,
                count(*) FILTER (WHERE team.is_winner = true) AS wizard_wins
               FROM battle
                 JOIN team ON team.battle_id = battle.id and team.wizard_id <> 'some-id'
              inner join "usersOnBattles" ON "usersOnBattles"."battleId" = battle.id
              inner join "user" ON "user".id = "usersOnBattles"."usersId"
              WHERE "user".id = 'some-uuid'
              GROUP BY team.wizard_id) wizard_battles
        GROUP BY wizard_battles.wizard_battles, wizard_battles.wizard_wins, wizard_battles.wizard_id
        ORDER BY 
            case when order_direction_input = 'asc' and order_input = 'wizard_win_rate' THEN wizard_win_rate end,
            case when order_direction_input = 'desc' and order_input = 'wizard_win_rate' THEN wizard_win_rate end desc;
    end;
    $$;
    I initially had more
    case when
    which all work, I only left the one that doesn't for readability. Funnily if I extract the query and populate the
    ORDER BY
    with
    wizard_win_rate
    it works! I tried a lot of things but nothing worked. Anyone has an idea?
    g
    • 2
    • 4
  • Select and order rows based on number of matched elements in array from foreign table in postgREST
    k

    KamilBartczak

    08/23/2022, 7:03 PM
    I'm creating simple supabase application and I want to construct postgREST query to select recipes and order them ascending by number of matched_ingredients https://stackoverflow.com/questions/73463521/how-to-select-and-order-rows-based-on-number-of-matched-elements-in-array-from-f
  • Is the service running fine? Getting Error [500] An error has occured Failed to fetch
    j

    jvlobo

    08/23/2022, 7:58 PM
    Hi everyone ๐Ÿ™‚ I'm not able to access my database on Supabase, I'm getting Error: [500]ย An error has occured: Failed to fetch all the time. It was working fine yesterday I believe. Is any of you having issues also? not sure if it is just an issue with my project or something general. According to https://status.supabase.com/ everything is fine at the moment. Thanks!
    r
    g
    • 3
    • 15
  • Testing Storage with Local Dev Instance
    h

    hankg

    08/23/2022, 8:32 PM
    According to the Local Development instructions (and from what I can gather) Storage API isn't available on the local instance for development. It is available from the Docker Compose script though. Is there a way to manually enable that or is there some other way I should be interacting with my local instance simulating Storage API?
    g
    • 2
    • 27
  • Realtime connection immediately closes
    b

    Bloodyaugust

    08/23/2022, 8:52 PM
    Hey friends! I'm attempting to use the "next" version of
    supabase-js
    (I'm on
    1.36.0-next.29
    specifically) to get realtime updates for a specific table. I've enabled realtime on the table, ensured that all replication toggles are on for the
    supabase_realtime
    replication, and enabled my table as a source for that replication. Here's the relevant client code:
    Copy code
    supabase
          .channel('*')
          .on('postgres_changes', { event: '*', schema: 'public', table: 'posts' }, (payload: any) => {
            console.log('Change received!', payload)
          })
          .subscribe()
    I'm in a React/TS app. The behavior that I'm seeing is that no updates are logged. When digging into the websocket messages, I see that the client immediately sends messages with events
    phx_join, access_token, phx_leave
    . All are acked, including with a
    phx_close
    message at the end. It continues to send heartbeats. Did I discover a bug in latest, or am I doing something wrong that causes the client to immediately leave?
    g
    • 2
    • 10
  • Does supabase not support multiple social providers for authentication?
    t

    TypeNull

    08/23/2022, 10:41 PM
    I am trying to authenticate users with discord or twitter or both if theyd like but it seems like you can only connect 1 3rd party at a time?
    g
    • 2
    • 3
  • Access insert values from policy
    r

    riccardo

    08/23/2022, 11:45 PM
    Hi i'm struggling for create a policy that check the inserted values, i have a "like button" function where i pass the "profile_id" of the user how i can check if this profile_id is belonging to the authenticated user? Also i need to check the like count based on the "post_id"
    g
    • 2
    • 6
  • Unable to exchange external code
    s

    so

    08/24/2022, 12:18 AM
    Hi folks, I'm facing a similar issue as this, except with v2 API: https://github.com/supabase/supabase/discussions/1192 Attempting Discord authentication with the following:
    Copy code
    js
    // index.js
    import { useState, useEffect } from 'react'
    import { supabase } from 'utils/supabaseClient'
    import Auth from 'components/Auth'
    import Account from 'components/Account'
    
    export default function Home() {
      const [session, setSession] = useState(null)
    
      useEffect(() => {
        supabase.auth.getSession().then(({ data: { session } }) => {
          setSession(session)
        })
    
        supabase.auth.onAuthStateChange((_event, session) => {
          setSession(session)
        })
      }, [])
    
      return (
        <div className="container" style={{ padding: '50px 0 100px 0' }}>
          {!session ? <Auth /> : <Account key={session.user.id} session={session} />}
        </div>
      )
    }
    Copy code
    js
    // Auth.js
    ...
      const { user, session, error } = await supabase?.auth?.signInWithOAuth({
        provider: 'discord',
      })
    ...
    The Discord API returns a 200 for the following request:
    Copy code
    js
    https://discord.com/api/v9/oauth2/authorize?client_id={REDACTED}&response_type=code&redirect_uri=https%3A%2F%{REDACTED}.supabase.co%2Fauth%2Fv1%2Fcallback&scope=email%20identify&state={REDACTED}
    But the callback returns this error:
    Copy code
    js
    http://localhost:3000/?error=server_error&error_description=Unable+to+exchange+external+code%3A+dQ9DfLMcgFgjlU2C5VO0nRwHzZu8OM
    with payload:
    Copy code
    js
    {
      error: server_error
      error_description: Unable to exchange external code: dQ9DfLMcgFgjlU2C5VO0nRwHzZu8OM
    }
    o
    • 2
    • 29
  • Unable to Register new user
    n

    Nilu

    08/24/2022, 12:45 AM
    Getting a database error of code: 500 { error_id: "ff166eab-f096-440b-96c8-ee168a48e5e5" msg: "Database error saving new user" } Replication instuctions: Go to https://bounti-web3.vercel.app/signup and signup via the email login - OTP seems broken for some reason
    g
    n
    • 3
    • 5
  • What's the best way to import 1M rows into a table? Ideally I can use the dashboard somehow
    u

    0xSmartCrypto

    08/24/2022, 6:55 AM
    AFAIK, csv import is available only on table creation? However, getting a 1M row csv file uploaded is not easy. Or is it? Are there better ways? I've managed to upload 100K rows so far. Would there be a way to append multiple tables into one large table (or view)? All the tables have the same header row. Thanks so much in advance!
    j
    • 2
    • 5
  • Can we give columns alias in supabase?
    s

    STILLWATER;

    08/24/2022, 7:41 AM
    Is it possible to give alias to a column in select in supabase js sdk.
    g
    • 2
    • 2
  • I cant access my table in database
    n

    nexik

    08/24/2022, 8:02 AM
    I just created new DB Table and can't access it. I'm the organization owner. Cant access any of the 3 tables
    p
    c
    +2
    • 5
    • 5
  • Bulk Insert RPC to return inserted values.
    s

    STILLWATER;

    08/24/2022, 8:23 AM
    Hey, Im bulk inserting values in sql using rpc in supabase, is it possible for it to return some column values in the same rpc, like ids and name etc for inserted values
    g
    • 2
    • 8
  • Recover the password from one userId
    a

    AdrianMsM91 {KBL}

    08/24/2022, 9:02 AM
    Hello, I need to recover the password from one userID, to check if the password you are putting in the Input is the same as the one you had. How can I get the password? Thanks for the help! โค๏ธ
    o
    g
    • 3
    • 3
  • Is Docker desktop really need to run the supabase in self hosting environment?
    s

    scheduledisplay

    08/24/2022, 10:07 AM
    I am running the virtual linux server. I am following the steps mentioned on the supabase self hosting webpage. By running this command "docker-compose up" I am facing the error "cannot allocate memory". I beleive it is the Docker desktop that requires more memory. So I would like to know is it really required to run docker desktop to run the supabase in docker in self hosted environment?
    s
    • 2
    • 1
  • Help with auth - localState vs Cookie
    w

    Wonday

    08/24/2022, 10:09 AM
    Hi there, I'm having some troubles with auth cookies (like some other issue i see) Supabase auth is a little confusing now, as the session is only stored in local storage, making it a bit of a pain to sync this with the cookie state. Some guidance on what the best and secure process here would be great. as it is not clear what the supabase functions provided do and don't do. Im building a web app with next. I love that supabase & RLS makes it secure to do a lot of calls directly from the client, which I am doing, but some actions I want to do only from api points with service_role key. however I want to protect these endpoints, so it made sense to me to use the supabase auth login and not setup a different solution. but the api methods seem to have changed and focus on client side now and it is not documented well how to use these securely 1. as in the example https://github.com/supabase/supabase/tree/master/examples/auth/nextjs-auth I am using an /api/auth endpoint with
    supabase.auth.api.setAuthCookie
    but this seems to only set, not clear the cookie? so we need to check for that case in
    supabase.auth.onAuthStateChange
    and then call another api route with
    supabase.auth.api.deleteAuthCookie
    ? 2. if the login is stored in localstate, the supabase client is just using the anon key? or when and where is the state token passed to the client? is it safe for the session to be stored in localstate? is it safest just to store the token in client side session and add it to each request ? 3. if i end up having both cookie and local storage, when the page loads, which of the two should take precedence? I would have thought the cookie, but supabase's focus on storage state is making me question this thanks for any helpers, pointers at guide's, threads or examples, i just couldnt really find anything discussing this. are there clear answers or does this all depend on the app?
    w
    j
    g
    • 4
    • 16
  • Supabase + Angular quickstart - some questions re guides in the docs
    s

    shtepa

    08/24/2022, 11:04 AM
    I went through the quickstart and really liked the experience. Thank you whoever put that educational material together and made it publicly available for free. Few questions I was curious to discuss: 1. why certain method(e.g.user, profile, session) are implemented using get getter, while others (e.g. signIn, signOut, authChanges, updateProfile etc) are implemented as regular methods 2. why is private supabase: SupabaseClient is declared before the constructor and not passed as an argument to constructor? 3. after certain period of time fetching for user (this.supabase.auth.user()) results in error saying that the token is expired. What is the default time period for token expiration? where can it be set to custom values? 4. in certain cases dependency injection is supplemented with readonly prefix like so
    constructor(private readonly supabase: SupabaseService) {}
    . What could go wrong? Reason I am asking is that when I use React with Supabase I don't remember using some similar guarding mechanisms so I thought I might be missing something here
    p
    • 2
    • 5
  • Event subscription is behaving strangely
    a

    andreaselia

    08/24/2022, 11:47 AM
    I have created a GitHub Gist so that it's easier to see the formatted code, but essentially the issue I'm having with it is that the subscribe events don't consistently fire. For example, when I boot up the app, it doesn't work unless I switch between a few other screens and then come back to refresh the state. It's probably something rather simple, but I think it's one of those "I've been staring at it for too long" issues ๐Ÿ˜… https://gist.github.com/andreaselia/dc504783e7d9d9875c5ab0e2e8e3fe75
    g
    • 2
    • 4
  • Region Update
    o

    ojg15

    08/24/2022, 12:20 PM
    Is it possible to change the region of a project once it's created? I couldn't see any option to do so.. Currently it's in Sydney and I want to move it to US East if that matters. It's a paid project
    g
    j
    • 3
    • 3
  • FetchError request to supabase_kong reason getaddrinfo ENOTFOUND supabase_kong_
    u

    0xSmartCrypto

    08/24/2022, 12:47 PM
    I'm using the local development env provided by
    supabase start
    Docker is running. However, when I call the api
    Copy code
    const { data, error } = await supabase
        .from('table_name')
        .select(`
          column1,
          column2
        `);
    I get an error message as such:
    Copy code
    {
      message: 'FetchError: request to http://supabase_kong_projectname:8000/rest/v1/table_name?select=... failed, reason: getaddrinfo ENOTFOUND supabase_kong_projectname',
      details: '',
      hint: '',
      code: 'ENOTFOUND'
    }
    Can someone please help?
    • 1
    • 2
  • Graphql Filters Don't Seem To Be Working
    d

    drewbie

    08/24/2022, 3:12 PM
    Trying to use the built in
    eq
    and
    neq
    filters for the autogenerated Graphql API.
    eq
    and
    neq
    set to a value seems to work. But
    eq: null
    and
    neq: null
    don't appear to be working. Not sure the best to debug this as I am testing it with the local development setup. Here is an example of the query I am trying to perform. A category has a parent_id which references another category. This query returns back nothing while there are in fact entries in the database that don't have a parent_id. Any help is appreciated! Thanks ``` query CategoriesCollection($filter: categoriesFilter) { categoriesCollection(filter: $filter) { edges { node { name parent_id } } } } { "filter": { "parent_id": { "neq": null } } }
    g
    • 2
    • 3
  • How to use custom fonts in email template?
    s

    Swapnil

    08/24/2022, 3:18 PM
    I am trying to implement the custom fonts using link tag shown below in photo.
    s
    g
    o
    • 4
    • 24
  • What should I learn
    f

    fefox74

    08/24/2022, 3:33 PM
    Hello I just learned react, node, express and mongoDB, and now I want to make a mobile app with react native, but i have to pay to use firebase, so what is the best tech stack to make a mobile app?
    e
    n
    t
    • 4
    • 4
  • Compare old and new value in update policy
    n

    Niki

    08/24/2022, 3:41 PM
    Given a
    table profiles (user_id uuid, role text)
    can I somehow compare the old and the new value in an insert policy? Example:
    Copy code
    sql
    create policy "Users can update own profile but cannot change role."
      on profiles for update
      with check ( auth.uid() = user_id and old.role != new.role);
    g
    • 2
    • 3
  • How can we build a bot?
    e

    e.sh

    08/24/2022, 4:00 PM
    has anyone done it?
    n
    s
    e
    • 4
    • 6
  • Why does this return an empty Array?
    d

    Deleted User

    08/24/2022, 4:33 PM
    I am trying to get all the data from the
    Scores
    table of my database. For some reason I get an empty array when logging
    data
    even though I already inserted a row into my table. Am I missing something? Code:
    Copy code
    js
        import { supabase } from '$lib/supabaseClient';
    
        async function getScoreList() {
            let { data, error } = await supabase
            .from('Scores')
            .select('*')
    
            console.log(data)
        }
    
        getScoreList()
    g
    • 2
    • 31
  • Typescript Type declaration on Inner Join?
    t

    Twisted Chaz

    08/24/2022, 4:41 PM
    I've got a query using the JS SDK that joins an inner table, but I'm not sure how I'm supposed to type it correctly.
    albums_genres.album_id
    has a squiggly and the error
    Argument of type '"album_genres.album_id"' is not assignable to parameter of type 'keyof AlbumGenre'.ts(2345)
    Copy code
    const { data: genres, error } = await supabase
      .from<AlbumGenre>("genres")
      .select("id, genre, album_genres!inner( sub_genre )")
      .eq("album_genres.album_id", album_id);
    and my current type is
    Copy code
    type AlbumGenre = {
      id: number;
      genre: string;
      album_genres?: {
        album_id: number;
        genre_id: number;
        sub_genre: boolean;
      }[];
    };
    l
    • 2
    • 1
  • Download Cold Storage
    b

    bsnow

    08/24/2022, 5:18 PM
    Hello, I have a ton of storage files and tables being used in supabase. I would like to download everything I have as a โ€œbackupโ€ about once a month onto an external hard drive, is there an easy way to do this? Iโ€™m on the pro tier but also donโ€™t want to rack up my bill
    g
    • 2
    • 1
1...8910...230Latest