https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • supabase return nothun from the db
    a

    Ammar Almuain

    04/15/2023, 6:02 PM
    Copy code
    const data = async () => {
        let { data: todos, error } = await supabase
        .from('todos')
        .select('id')
        return todos
    }
    g
    • 2
    • 1
  • When to use RLS?
    k

    kylelovesyou

    04/15/2023, 7:12 PM
    If you trust the client is sending in the correct data (e.g. post request creating a new post for a user)- do I need to implement RLS? If a larger team of devs are working on the client- I could then see the need, but otherwise, can I simply leave RLS disabled on my tables?
    g
    • 2
    • 10
  • SQL Editor runs old query
    m

    Maz

    04/15/2023, 7:28 PM
    On Firefox (haven't tested other browsers), when using the Supabase SQL Editor, I often see the last query I ran run instead of the current one in the text editor. This seems like a pretty serious issue if the old query mutated data. It's also possible the old query isn't running but the output text is instead persisting and overwriting the current query. Ultimately, this means I find myself having to use the Run button twice in order to get my query to actually run. Anyone else see this?
    g
    • 2
    • 2
  • Best practice for syncing auth.users email field
    m

    Maz

    04/15/2023, 7:56 PM
    I am following the recommended best practices for keeping a
    profiles
    table that references
    auth.users
    . This works fine when
    profiles
    contains additional columns the
    auth.users
    table does not, but what if I want to expose the
    auth.users
    email
    field to this
    profiles
    table and keep them in sync? Should I use a trigger or is there some new postgres feature I'm not aware of to "mirror" a column from another table, like generated columns?
    g
    • 2
    • 3
  • SQL Editor no longer sorting saved queries :(
    j

    jarnold

    04/15/2023, 8:36 PM
    Can we get that back pls 😄
    g
    • 2
    • 2
  • difference between realtime and subscription
    a

    AMZ7860

    04/15/2023, 9:50 PM
    hello , acutally there is 2 option to listen database changes, we can use realtime stream also and we can subscribe also, for particular table for particular row changes we can listen with both methods, so whats the difference between both methods, and in which situation we use which method? can any one explain please thankyou...
    g
    • 2
    • 5
  • Duplicate Refresh Tokens
    n

    nahtnam

    04/15/2023, 9:52 PM
    I set my refresh time in supabase to 5 seconds and I noticed that the network logger shows two refresh token POST requests every 5 seconds. I'm assuming this isn't normal, any speculations as to what causes something like this? I only have one instance of
    createClient
    (at the root level, not inside of a function/component).

    https://cdn.discordapp.com/attachments/1096915884532060241/1096915885068918884/image.pngâ–¾

    g
    • 2
    • 10
  • How to only return one value, rather than nested objects, with deeply nested data
    j

    JamieGreg

    04/15/2023, 10:05 PM
    I'm querying for some data that is nested a few levels down, and as you would guess it returns a few nested objects. Is there a way of returning the value on its own?
    Copy code
    .select(`
      *,
      moduleId: lists(boards(modules(id)))
      )
    `)
    Im looking for the returned value to be something like
    Copy code
    moduleId: 11
    rather than
    Copy code
    moduleId: {
      boards: {
        id: 11
      }
    }
    g
    • 2
    • 2
  • Create Empty Folders from Existing Folder
    z

    zach

    04/15/2023, 10:08 PM
    Hi there! After signing up a user, I'm looking to create two empty child folders within my existing 'user-images' parent folder (which sits inside my 'images' bucket). The end result should look something like the attached screenshot from my supabase dashboard. 1) user-
    ${data.user.id}
    2) properties Code for my handler function on signup is attached. The first part of it works (signing up the user with email, password, first_name, and last_name). Its just the three storage requests after that which are not working. I get the below error for all 3 storage requests (attached is the name of each from my Network tab in Chrome dev tools): {statusCode: "404", error: "Not found", message: "The resource was not found"} I'm guessing its something to do with the path parameters I'm passing into .upload() for each of the 3 requests. If it is, can someone guide in the right direction here?

    https://cdn.discordapp.com/attachments/1096919987681243146/1096919987886751914/handler-function.pngâ–¾

    https://cdn.discordapp.com/attachments/1096919987681243146/1096919988260048977/name-of-requests.pngâ–¾

    https://cdn.discordapp.com/attachments/1096919987681243146/1096919988503326800/ideal-structure.pngâ–¾

    g
    • 2
    • 13
  • Do I have to verify if a JWT token is expired?
    d

    DanMossa

    04/15/2023, 11:37 PM
    I have an RPC Postgres function I created with security definer. If a user with an expired JWT token calls this RPC function, will it work? Or do I need to manually verify it's expiration due to it being a security definer role? Thanks!
    g
    • 2
    • 13
  • Are there any ways to alter tables through Supabase's SDK?
    g

    Guy Rozen

    04/16/2023, 12:05 AM
    Supabase's AI claims it is possible to both run an "alterTable" function and query SQL scripts straight from the SDK itself, without calling a Postgres function saved through the UI. I haven't found any mentions for these claims anywhere else. I am aware it is in an experimental stage and that it may write incorrect answers, but is it possible to do so somehow? As in, alter schemas/tables through the project's code without being forced to constantly go to the UI? An initialized Supabase sdk with a service role key also works.
    g
    s
    • 3
    • 8
  • Enable update for authenticated users only
    s

    supafloh

    04/16/2023, 1:11 AM
    Would this be correct for properly allowing authenticated users to update rows in the table? I used the "Enable insert for authenticated users only" template, and changed it from insert to update, but the "Using expression" field appeared, not sure if I need to add anything there. To go the extra mile, how can I make it so they can only update a specific column?

    https://cdn.discordapp.com/attachments/1096966101503586324/1096966101704908840/image.pngâ–¾

    g
    • 2
    • 1
  • Custom cache settings for specific buckets
    j

    jarnold

    04/16/2023, 1:23 AM
    Is it possible to configure caching settings for specific buckets? From my understanding, we can only apply cache settings globally to all buckets. My reasoning is to avoid double caching since I do some heavy processing once the data is fetched and I cache that instead with swr. But, I fetch from other storage buckets where I'd like to keep the caching from supabase.
  • Update query results in "Results contain 0 rows"
    s

    supafloh

    04/16/2023, 1:41 AM
    Copy code
    js
    const {data : updateData, error} = await supabase
      .from('posts')
      .update({
        description: descriptionValue
      })
      .eq('id', data.id)
      .select('*')
      .single()
    if (error) console.log(error)
    console.log(updateData)
    Request URL ``https://[myproject].supabase.co/rest/v1/posts?id=eq.52&select=*`` Result:
    Copy code
    code: "PGRST116"
    ​
    details: "Results contain 0 rows, application/vnd.pgrst.object+json requires 1 row"
    ​
    hint: null
    ​
    message: "JSON object requested, multiple (or no) rows returned"
  • How to point to foreign key in RLS?
    c

    Canman

    04/16/2023, 2:28 AM
    I want to check the foreign key profile's id to see if it matches the auth user. What is the correct syntax for that? Something like this, though this isn't right? (auth.uid() = creator.id)
    g
    • 2
    • 5
  • Unable to deploy functions
    e

    Elias

    04/16/2023, 3:35 AM
    I'm running into the following error after doing
    Copy code
    supabase functions new test
    Error
    Copy code
    Version 1.30.3 is already installed
    Bundling posts
    Error: Error bundling function: signal: abort trap
    file:///src/import_map.json
    file:///src/index.ts
    assertion failed [block != nullptr]: BasicBlock requested for unrecognized address
    (BuilderBase.h:550 block_for_offset)
    a
    s
    • 3
    • 4
  • Email auth password strength
    k

    KBar

    04/16/2023, 7:03 AM
    Hello everyone! I have a simple question: is it possible to configure password strength for email auth? I'd like to lower the requirements to a single character. I know it's insecure but that's not my decision so what can I say? Thanks for this wonderful service!
    g
    s
    • 3
    • 3
  • Remix Project Connection to Supabase
    m

    monkykap

    04/16/2023, 10:21 AM
    Hi there, just starting off, following a tutorial. I'm getting an issue where the call to supabase is hanging. Maybe something with the function:
    Copy code
    import supabase from "lib/supabaseClient"
    
    export const loader = async({}) => {
      console.log("entered");
      const { data } = await supabase.from('themes').select();
      console.log("exited")
      return { data };
    }
    
    export default function Index() {
      const{ data } = useLoaderData();
      return <pre>{JSON.stringify(data, null, 2)}</pre>;
    }
    Function enters but doesn't exit for a long time, and then shows null.
    g
    • 2
    • 2
  • Invalid input syntax for type Integer
    c

    COLD1

    04/16/2023, 10:46 AM
    Hi, I am getting an error that doesn't make sense. I'm entering an integer for the put request, but even with parseInt() added I still get 'invalid input syntax for type integer'.
    Copy code
    javascript
    exports.updateArticle = [
        body('article_id').isInt(),
        body('author_id').isInt(),
        body('article_title').optional().notEmpty(),
        body('summary').optional().notEmpty(),
        body('content').optional().notEmpty()
    ,
        async (req, res, next) => {
            try {
                const errors = validationResult(req);
                if (!errors.isEmpty()) {
                    return res.status(400).json({ errors: errors.array() });
                }
    
                const { data: article, error } = await supabase
                    .from('articles')
                    .update({
                        article_id: req.body.article_id,
                        author_id: req.body.author_id,
                        article_title: req.body.article_title,
                        summary: req.body.summary,
                        content: req.body.content,
                    })
                    .eq('article_id', parseInt(req.params.id))
                   
    
                if (error) {
                    return next(error);
                }
    
                res.json({ message: 'Article updated successfully!' });
            } catch (error) {
                next(error);
            }
        },
    ];

    https://cdn.discordapp.com/attachments/1097110669041610793/1097110669389746247/image.pngâ–¾

    g
    • 2
    • 7
  • cors storage self hostet / easy way to backup the DB
    l

    Limuz

    04/16/2023, 12:45 PM
    Hello, when i try self hosting on a route server the storage always response with a cors error (api for db works) i reseted the config multpile times only switch the api url to domain or disabled ngnix and tried it with the ip i still cant get it to work any suggestion ? best regards Limuz P.S does anyone know how to back up the database ?
    • 1
    • 1
  • Module not found .supabase/denos/build.ts
    s

    shultz

    04/16/2023, 1:18 PM
    when running supabase functions deploy my-functions supabase is looking for it in / so something like error: Module not found: **/home**/shultz/prj/curr/my-project**/home**/shultz/.supabase/denos/build.ts
  • Self-Hosting Storage gives error net::ERR_NAME_NOT_RESOLVED
    v

    ven

    04/16/2023, 2:57 PM
    Hello friends - I am getting an net::ERR_NAME_NOT_RESOLVED when I try to retrieve images from my locally hosted storage bucket. I have not been able to find anything on stackoverflow or this discord server that would help me resolve this issue. I have attached two images. 1. the browser console showing the error 2. the supabase studio view of the storage bucket. what is weird is that the studio does not show the images in the bucket either. I tried pasting the image URL into a new browser window and that didn't work either. I wasn't able to retrieve the image. any thoughts? thank you

    https://cdn.discordapp.com/attachments/1097173938913689770/1097173939144368168/browser_console.jpgâ–¾

    https://cdn.discordapp.com/attachments/1097173938913689770/1097173939416993892/studio_view_of_the_storage_bucket.jpgâ–¾

    g
    s
    • 3
    • 18
  • Flaky CORS (preflight not returning cors headers)
    j

    jarnold

    04/16/2023, 3:12 PM
    This is local development. The preflight is blocking. I can see that the function is being called and following the OPTIONS path. Seems like the return doesn't include the cors header though which is likely the problem. I've followed the setup steps as instructed https://supabase.com/docs/guides/functions/cors Can't seem to fix with past threads unfortunately What's odd is that it's been working for weeks then suddenly yesterday I got this error. I restarted everything and then it worked for the rest of the day. Today it's not working Running functions with
    supabase functions serve --all

    https://cdn.discordapp.com/attachments/1097177678412533903/1097177679150727168/CleanShot_2023-04-16_at_11.09.32.pngâ–¾

    https://cdn.discordapp.com/attachments/1097177678412533903/1097177679494652005/CleanShot_2023-04-15_at_19.53.36.pngâ–¾

    https://cdn.discordapp.com/attachments/1097177678412533903/1097177679771488388/CleanShot_2023-04-15_at_19.55.00.pngâ–¾

    https://cdn.discordapp.com/attachments/1097177678412533903/1097177680069271552/CleanShot_2023-04-15_at_19.54.49.pngâ–¾

    s
    a
    +4
    • 7
    • 48
  • PGVector: query_embedding return null
    p

    Peterson

    04/16/2023, 3:19 PM
    Hello everyone, I'm following the tutorial https://supabase.com/blog/openai-embeddings-postgres-vector Everything working perfectly but when I search the embeddings they always return null.
    g
    • 2
    • 5
  • useSession (NextJS) returns null for a quick second, before returning session.
    m

    MATTI

    04/16/2023, 3:31 PM
    When using the useSession hook for NextJS, I run into this problem where it returns null for a quick second before returning the actual session (If one exists ofc). This is a bit of a problem since I am trying to do protected routes depending on if a session exists, or return the user to signin if not. How would I go about fixing this?
    m
    • 2
    • 1
  • `supabase start` fails with schema `vault` doesn't exist
    h

    hkg

    04/16/2023, 3:50 PM
    I started a project and ran:
    Copy code
    npx supabase link --project-ref <id>
    then
    Copy code
    npx supabase start
    then tried to get initial migration from remote
    Copy code
    npx supabase remote db commit
    and when I tried to:
    Copy code
    npx supabase db reset
    I got:
    Copy code
    Applying migration 20230416154524_remote_commit.sql...
    Error: ERROR: schema "vault" does not exist (SQLSTATE 3F000)
    At statement 15: --
    -- Name: supabase_vault; Type: EXTENSION; Schema: -; Owner: -
    --
    
    CREATE EXTENSION IF NOT EXISTS "supabase_vault" WITH SCHEMA "vault"
    s
    g
    • 3
    • 20
  • Create anonymous rule
    l

    lecookie

    04/16/2023, 4:11 PM
    How could I create a rule that would allow user to read from the database while being anonymous but not modify it.
    g
    • 2
    • 1
  • How to query by ``element in array``?
    m

    magenta

    04/16/2023, 4:55 PM
    Hi there, I have the following table which has a column ``domains[]``, which holds an array of texts:

    https://i.imgur.com/mLPxI6B.pngâ–¾

    Now I'd like to get the rows, where "restaurant.gastrobit.de" is in the ``domains[]`` column. I assumed ``.overlaps()``[1] would be the correct method, as it is described as finding columns, where a common element exists:
    Copy code
    js
      const { data: restaurantId, error } = await supabase
        .from('restaurants')
        .select('*')
        .overlaps('domains', ["restaurant.gastrobit.de"]) // this doesn't work
    However, this results in an empty array if applied on the table from above. [1] https://supabase.com/docs/reference/javascript/overlaps
    • 1
    • 2
  • Error - Bad resource ID on functions serve all
    m

    marc

    04/16/2023, 5:00 PM
    hey I want to use the cli to run all edge functions so i do :
    supabase functions serve --env-file ./supabase/.env --import-map ./supabase/functions/import_map.json
    and I get :
    Copy code
    at async HttpConn.nextRequest (ext:deno_http/01_http.js:93:21)
        at async serve (https://deno.land/x/oak@v12.1.0/http_server_native.ts:62:46)
    [uncaught application error]: Error - Bad resource ID
    
        at async HttpConn.nextRequest (ext:deno_http/01_http.js:93:21)
        at async serve (https://deno.land/x/oak@v12.1.0/http_server_native.ts:62:46)
    [uncaught application error]: Error - Bad resource ID
    
    ... (in an infinit loop when i make an http call to the function)
    it's working fin when I use the cmd to serve only one function I use supabase js in my fonctions maybe this can came from the host of the docker, when my edge function try to call with supabase-js...
    supabase_deno_relay_supabase
    (I see the --allow-net https://github.com/denoland/deno_docker options for docker but not sure if it can help) (i'm on mac os M2) thanks for your time 🙂
    • 1
    • 1
  • Can i change location of supabase project?
    j

    Jaaneek

    04/16/2023, 5:27 PM
    I would like to change region in which my supabase project is deployed, how can I do it?
    g
    • 2
    • 2
1...181182183...230Latest