https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • File system access error
    s

    Shawn Conecone

    02/08/2023, 10:52 AM
    Hello, I have this script that calls this function in the edge function:
    Copy code
    async function getTemplateImage() {
      return await Image.decode(await Deno.readFile("./SKDN-template.jpeg"));
    }
    with the
    SDKN-template.jpeg
    located on the same level as this script. When I tried invoking this after deployment, I got this error
    Copy code
    Error: file system access error (code 42), id:d5072e47-1328-4d9d-b00a-0813f58c11b4
        at async Object.readFile (deno:deploy/js/02_fs.js:55:12)
        at async getTemplateImage (file:///src/createPdf.ts:14:31)
        at async createReportPngs (file:///src/createPdf.ts:103:25)
        at async Server.<anonymous> (file:///src/index.ts:11:23)
        at async Server.#respond (https://deno.land/std@0.168.0/http/server.ts:221:24)
    I'm aware that deno needs explicit permission to read/write to system (https://deno.land/manual@v1.29.1/basics/permissions) but not sure how to allow read in the edge. Any suggestions? Thanks!
    m
    • 2
    • 2
  • How do I query data from two tables filtering on foreign key?
    b

    bkyerv

    02/08/2023, 1:21 PM
    I have two tables
    author (that has id and name columns)
    and
    news (that has title and author_id which is a foreign key pointing to the id in the author table
    . How do I structure the query so that it returns
    title
    and
    author of the title
    ? I tried
    from('news').select('title', 'author('name')).eq('news.author_id', 'author.id')
    . In sql my query would look like
    select title, name from news inner join author on news.author_id=author.id
  • How does PG_Graphql work with 100s-1000s of schemas within a database
    a

    algads

    02/08/2023, 2:18 PM
    I am wondering about the internals of PG_Graphql and how it's general workflow operates. Let's say we have 500 schemas in one database. Each of those schemas has its own tables and columns which may be different from every other schema (or could be the same - depends on whether the customer changed their data model). Does PG_Graphql read every single schema at startup and then store the schema in mem and then change it on DDL updates? Are the schemas lazy loaded? IE: when a schema is queried, if its graphql representation does not exist, its generated and stored in memory? Or is PG_Graphql really a compiler that works at request time - converts the graphql request into SQL in real time and then just stored prepared statements if possible thus trading execution speed in return for not really impacting memory?
    a
    • 2
    • 1
  • Local supabase storage: 404 errors
    k

    Kjell

    02/08/2023, 2:55 PM
    Hey all, When I try to connect to supabase storage and list the files, kong returns 404 errors. The address is not found: Kong log: 192.168.1.215 - - [08/Feb/2023:14:53:01 +0000] "GET /storage/v1/bucket HTTP/1.1" 404 8460 "-" "supabase-py/storage3 v0.5.0" Executed script: supabase: Client = create_client(SB_URL, SB_KEY) storage_client: SupabaseStorageClient = supabase.storage() all_buckets = storage_client.list_buckets() print(all_buckets) This script was woking beofre (last week) but now it doesn't work anymore, which i find very remarkable as I didnt update the python client, nor the kong api routing. Does anyone have a clue as to why this has happened?
    g
    • 2
    • 4
  • Are there any examples of Supabase + GraphQL in Sveltekit?
    m

    Monimolimnion

    02/08/2023, 2:59 PM
    Basically, title - I'm looking to use Supabase with a Sveltekit app and using GraphQL would be fantastic but there doesn't seem to be much documentation for it yet. Are there any tutorials or examples that anyone knows of?
  • Has anyone here tried to connect their Supabase database to Trevor.io? (looking for user feedback!)
    r

    RJSTrevor

    02/08/2023, 3:48 PM
    Disclaimer: I'm Rogan from Trevor.io πŸ‘‹ We think out database connector page might not be set up very well for helping people get setup and start querying their Supabase database on Trevor. Has anyone tried & has any feedback?
  • Common storage, functions, & auth for more than one site?
    k

    Kenneth J Hughes

    02/08/2023, 4:18 PM
    Design question: Are there any problems with having a single Supabase instance be accessed by more than one site/app? I have a requirement that users' credentials and data be shareable across sites/apps and am looking for any upfront design guidance or considerations you might offer. Thanks for any suggestions or insights.
    g
    • 2
    • 2
  • Can Admin Reset Users Password?
    a

    adam21xc

    02/08/2023, 4:38 PM
    Is it possible to reset a users password on the supabase auth admin panel as opposed to having to send the user a password reset email? Firebase has this functionality built in where the admin can change the users password.
    g
    • 2
    • 1
  • RLS doesn't seem to read user role
    j

    Jim

    02/08/2023, 4:44 PM
    Hey I have a policy for a
    locations
    table to only allow users who match an "ADMIN" role from their role table to read it, which looks like this:
    Copy code
    sql
    (
    EXISTS 
      (
      SELECT 1
        FROM roles r
        WHERE (
          (r.id = auth.uid())
          AND
          (r.role = 'ADMIN'::text)
        )
      )
    )
    For some reason though it seems to be blocking access as a user. What can I do to debug this? Again pretty new to SQL so it may be something obvious. Thanks!
    g
    • 2
    • 6
  • pgsodium: encrypting columns in two different tables fails
    t

    turner

    02/08/2023, 4:46 PM
    Hi everyone, I have two similar tables, within both I want to encrypt the content of one column (in this example its the column is called
    secret_column
    in both tables).
    Copy code
    sql
    CREATE TABLE table_name1 (
       id_1 uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
       key_id_1 uuid NOT NULL REFERENCES pgsodium.key(id) DEFAULT (pgsodium.create_key()).id,
       nonce_1 bytea NOT NULL DEFAULT pgsodium.crypto_aead_det_noncegen(),
       secret_column_1 text NOT NULL DEFAULT 'undefined'::text
    );
    
    CREATE TABLE table_name2 (
       id_2 uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
       key_id_2 uuid NOT NULL REFERENCES pgsodium.key(id) DEFAULT (pgsodium.create_key()).id,
       nonce_2 bytea NOT NULL DEFAULT pgsodium.crypto_aead_det_noncegen(),
       secret_column_2 text NOT NULL DEFAULT 'undefined'::text
    );
    Copy code
    sql
    SECURITY LABEL FOR pgsodium
      ON COLUMN table_name1.secret_column_1
      IS 'ENCRYPT WITH KEY COLUMN key_id_1 NONCE nonce_1 ASSOCIATED id_1';
    
    SECURITY LABEL FOR pgsodium
      ON COLUMN table_name2.secret_column_2
      IS 'ENCRYPT WITH KEY COLUMN key_id_2 NONCE nonce_2 ASSOCIATED id_2';
    I am able to set the security labels for each table separately, but If I want to add both, it fails, giving me the error:
    Copy code
    sql
    Failed to run sql query: must be owner of relation table_name1
    I am new to this topic and looked up every source I can find online, but none could solve my problem. I really appreciate your help! Thank you in advance Tim πŸ™‚ I also opened an issue in pgsodium and will update if once I find a solution: https://github.com/michelp/pgsodium/issues/73
    • 1
    • 1
  • Enabling new extensions -- a much simpler question this time
    i

    InASunshineState

    02/08/2023, 4:55 PM
    I saw the blog post for pg_vector and was able to find the embedding for a bunch of my test tags, and the indexing is lightning fast. So cool! But I had to make a new project, per the blog post. The reason I was testing it is because we could make use of it in my existing project. Is it as simple as pausing and unpausing? Or should I reach out to support? (I bug them a few times a month it seems so if nobody minds being collectively bugged here I thought I'd lean on your hospitality before trying) We are using that database almost all hours because of devs in different time zones so I'd like to make sure it's going to work -- or go straight to support if they can do it without a substantial downtime)
    g
    • 2
    • 4
  • STMP Server (Email)
    d

    DisamDev

    02/08/2023, 5:22 PM
    Hi, I would like to know how the STMP email system works, by default the emails are sent by @mail.app.supabase.io and I would like them to be sent from my company email. I think that's what STMP is for, right? Or if not, I would like to know how to do it and how it works to change it.
    g
    • 2
    • 4
  • Retool for user admin
    j

    joshuabaker

    02/08/2023, 5:48 PM
    Currently trying to put together an admin interface using Retool. End users are non-techie so keen to provide a really simple, hard-to-mess-up interface. Picking apart the client, the
    /rest/v1/admin/users
    endpoints referenced for
    createUser
    ,
    updateUserById
    , etc. don’t seem to work for some reason (trying in Postmark). The responses are always empty (i.e.
    {}
    ). It’s quite frustrating that the documentation is so thin for the REST API. Are there plans to wind this down? What am I missing here?
    g
    • 2
    • 20
  • json.decoder.JSONDecodeError while trying to insert data using supabase-python
    h

    Hank Stark

    02/08/2023, 6:20 PM
    Upon executing the code given in the github repo for inserting data, a "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" error is raised. Am I doing something wrong here? Or is it a bug?
    o
    g
    s
    • 4
    • 16
  • Implementing business logic before a request is handled.
    h

    Hugos

    02/08/2023, 6:47 PM
    I’m making a chess website utilizing supabase realtime for game updates and was wondering what the best approach was to checking wether a chessmove is legal or not before the database is updated, should I do this with policies?
    g
    • 2
    • 12
  • Getting type error while listening to realtime "delete" events
    j

    jcurbelo

    02/08/2023, 6:53 PM
    I'm getting the following error:
    Copy code
    Uncaught TypeError: Cannot convert undefined or null to object
        at Function.keys (<anonymous>)
        at Module.convertChangeData (transformers.js?0598:48:1)
        at RealtimeChannel._getPayloadRecords (RealtimeChannel.js?153b:446:27)
        at eval (RealtimeChannel.js?153b:332:68)
        at Array.map (<anonymous>)
        at RealtimeChannel._trigger (RealtimeChannel.js?153b:319:14)
        at eval (RealtimeClient.js?f065:290:1)
        at Array.forEach (<anonymous>)
        at eval (RealtimeClient.js?f065:290:1)
        at Serializer.decode (serializer.js?d74c:12:1)
        at RealtimeClient._onConnMessage (RealtimeClient.js?f065:281:1)
        at conn.onmessage (RealtimeClient.js?f065:102:1)
    while listening to realtime events, this is a snippet of my code (react):
    Copy code
    typescript
    supabase.channel('apps-db-changes')
            .on(
              REALTIME_LISTEN_TYPES.POSTGRES_CHANGES,
              {
                event: REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.ALL,
                schema: 'public',
                table: 'App',
              },
              () => fetchApps()
            )
            .on(
              REALTIME_LISTEN_TYPES.POSTGRES_CHANGES,
              {
                event: REALTIME_POSTGRES_CHANGES_LISTEN_EVENT.ALL,
                schema: 'public',
                table: 'Installations',
              },
              () => fetchApps()
            )
            .subscribe()
    it works fine with insertions and updates, but with deletes it gives me the error, I also checked ws messages:
    g
    • 2
    • 36
  • How to handle types when querying data and joining tables?
    l

    Lukas V

    02/08/2023, 6:53 PM
    Hello, I have products table and I used supabase-cli to generate types for my database. Here is how my
    products
    table types looks like:
    Copy code
    products: {
            Row: {
              active: boolean | null;
              created_at: string | null;
              created_by: string | null;
              default_price: string | null;
    As you can see
    default_price
    type is string id that points to another table. Now when I do joins whilst querying data:
    Copy code
    let {
          data: products,
          error,
          count
        } = await supabase
          .from('products')
          .select('*, default_price (*), offer_price_id (*)')
    default_price
    is no longer a string, but the price object, so what is the best way to handle this with typescript? Should I create new type and simply cast it with
    as
    return type:
    Copy code
    return products as ProductsWithPricesCombinedType;
    or is there another better method to do this?
  • NextJS getUser()
    d

    DisamDev

    02/08/2023, 8:45 PM
    I have a problem in Next.js, I want to get the user by
    const { data: { user } } = supabase.auth.getUser()
    to use it later in the code but I can't put the async to the path function because it gives error, and if I make a function with the await/async inside I can't export it outside to use it, how can I do it?
  • Best practices for NextJS server-side Supabase usage
    m

    martinbot

    02/08/2023, 8:55 PM
    Hello! I am currently in the process of exploring using Supabase for our NextJS application, which can be considered a simple CRUD app. I've gone through the docs and a few starter guides for NextJS and they all seem to show that you can initialize the Supabase client directly from frontend code and begin fetching data that way. With the right RLS policies, you can make sure that your users will only be accessing data they should be able to. In my case, though, I would prefer not to provide a direct connection between the frontend and our DB. Instead, I would like to have the frontend make normal API calls to my NextJS API endpoints and have those endpoints interact with Supabase. This would give us one more level of security and control before returning data to the user. I know there are some tradeoffs with this approach, but this is what I feel most comfortable with. Now that I've added a bit of context... my questions are the following: At which point in my app should I create the Supabase client? Per API request? That seems wasteful, but I think due to the serverless nature of NextJS APIs, I can't get around that. Would I run into any limiting issues with this approach?
  • Using NextAuth with Supabase roles?
    p

    Pythonic

    02/08/2023, 9:20 PM
    Just posting this again because it got buried: Hi there, I've been using NextAuth.js with Supabase and things have been going well. I was trying to implement an "admin" role that some users have to get increased priveledges so in my users table I have a column role and I have a function called next_auth.role() which does the following:
    Copy code
    sql
      select
        coalesce(
            nullif(current_setting('request.jwt.claim.role', true), ''),
            (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'role')
        )::text
    I'm pretty sure this should be working as intended, however I'm getting a strange error after manually giving myself the role supabase_admin and making a request with the JWT that includes the role
    Copy code
    Uncaught (in promise) Error: permission denied to set role "supabase_admin"
    Anyone know what this means and how to avoid it?
    g
    • 2
    • 1
  • Is there a way to join an array column of ids?
    t

    TheBuilderJR

    02/08/2023, 9:31 PM
    So it's pretty easy to do something like select(, prices()), and superbase automagically joins with the foreign key But what if I have a product that has a bunch of prices. So instead of price_id, I might have price_ids. And when I materialize the product, I want to join the array of price_ids with all the prices in the price table. Is there a way to do that?
    g
    • 2
    • 4
  • How can I retrieve the User session in a SvelteKit API Route?
    j

    Jennn

    02/08/2023, 9:32 PM
    One-Liner: API Routes in SvelteKit take in a
    RequestEvent
    argument which is not compatible with
    ServerLoadEvent
    that
    getServerSession(event)
    expects. -- In SvelteKit, you can send HTTP Requests to any API routes you define as
    +server.ts
    files (as opposed to the usual
    +page.server.ts
    . In the docs, the
    sveltekit-auth-helpers
    provide a
    getServerSession(event)
    that takes in a
    ServerLoadEvent
    . But in contrast, API routes take in a
    RequestEvent
    type (https://kit.svelte.dev/docs/types#public-types-requestevent). Is there a way around this?
    • 1
    • 1
  • PGVector in existing database
    a

    amankishore

    02/08/2023, 10:04 PM
    Hello I want to add pgvector to an existing database. When I run this command
    create extension vector;
    I get this error:
    Copy code
    Failed to run sql query: could not open extension control file "/var/lib/postgresql/extension/vector.control": No such file or directory
    g
    a
    +2
    • 5
    • 16
  • can I add postgres extensions no listed under database/Extensions?
    a

    Amor Fati

    02/08/2023, 11:25 PM
    The one I'm interested in is this one https://github.com/edoceo/pg-ulid
  • using presence to track total online users
    b

    baddoh99

    02/09/2023, 12:22 AM
    i've been trying to use presence to create some sort of game lobby screen where when a player visits the view they're able to view all the other players on the specific view (channel) but i've been pretty unsuccessful with it. the code i currently have tracks when a player joins the view (channel) but not when they leave. see code snippet below:
    Copy code
    javascript
      useEffect(() => {
        const eventLobbyChannel = supabase.channel(
          `event-${event.event_id}-players`,
          {
            config: {
              presence: {
                key: user.id,
              },
            },
          }
        );
        eventLobbyChannel.on('presence', { event: 'sync' }, () => {
          const state = eventLobbyChannel.presenceState();
          console.log(`Online users:  `, Object.keys(state).length);
        });
    
        eventLobbyChannel.on('presence', { event: 'join' }, (newPlayer) => {
          console.log(`New player: `, newPlayer);
        });
    
        eventLobbyChannel.on('presence', { event: 'leave' }, (oldPlayer) => {
          console.log(`Player left: `, oldPlayer);
        });
    
        eventLobbyChannel.subscribe(async (status) => {
          if (status === 'SUBSCRIBED') {
            const trackUserId = await eventLobbyChannel.track({ userId: user.id });
            console.log('Tracked : ', trackUserId);
          }
        });
    
        return () => {
          supabase.removeChannel(`event-${event.event_id}-players`);
        };
      }, []);
    what might i be doing wrong?
    d
    e
    • 3
    • 2
  • Is there an alternative way to join tables to what I'm doing here:
    y

    yayza_

    02/09/2023, 12:39 AM
    Currently I'm doing this:
    Copy code
    js
        const { data: attributes, error } = await locals.supabase
            .from("attributes")
            .select("*, categories:category_attributes(categories(id, name))");
    Response:
    Copy code
    {
      "id": 1,
      "name": "Flavor",
      "categories": [
        {
          "categories": {
            "id": 26,
            "name": "Candy"
          }
        },
        {
          "categories": {
            "id": 27,
            "name": "Beverages"
          }
        }
      ]
    }
    Is there a cleaner way that would get me the response like :
    Copy code
    {
      "id": 1,
      "name": "Flavor",     
      "categories": [
       {        
            "id": 26,
            "name": "Candy"
        },      
            "id": 27,
            "name": "Beverages"   
        }
      ]
    }
    I currently have 3 tables,
    categories
    ,
    attributes
    , and
    category_attributes
    , which is just a many to many relationship between those two (thinking I should change this)
    g
    • 2
    • 8
  • auth component redirect not working
    h

    Holland

    02/09/2023, 1:20 AM
    Copy code
    <Auth
              redirectTo='http://localhost:3000/home'
              supabaseClient={supabase}
              providers={['google']}
              appearance={{ theme: ThemeSupa }}
            />
    I want that to redirect to /home. But on a successful signin that returns an instance of a user, no redirect happens. How do I fix this?
    g
    • 2
    • 19
  • Importing data types not included in supabase
    e

    elliott

    02/09/2023, 1:45 AM
    I have a csv that includes a datatape, "geometry" from postgis. If I try to import this to supabase, supabase insists on turning that into a text. Is there any way to import into supabase and maintain special data types? Postgis is supported as a supabase extension, it's just the import that I can't figure out.
    g
    • 2
    • 11
  • oauth providers styling
    a

    alana

    02/09/2023, 2:01 AM
    have been trying to figure out how to move this "sign in with google" button below sign in and hitting a dead end. any tips? here's my current code:
    Copy code
    <div className="row">
                  <Auth
                    supabaseClient={supabase}
                    appearance={{
                      theme: ThemeSupa,
                      variables: {
                        default: {
                          colors: {
                            brand: "#f2acb9",
                            brandAccent: "#f2acb9",
                          },
                        },
                      },
                    }}
                    providers={["google"]}
                  />
                </div>
  • Supabase-js RPC call to Postgres function
    d

    Decaf Coffee

    02/09/2023, 2:39 AM
    Is there a way to restrict certain users from using the
    supabase.rpc('function')
    call similar to RLS? Maybe I'm misunderstanding, but if a Postgres function is marked as
    Security Definer
    , wouldn't any user calling the function via
    rpc()
    effectively gain service role level access?
    g
    • 2
    • 9
1...124125126...230Latest