https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Using transactions from Client (when need to create Root object and it's children altogether)
    k

    Konstantin Trunin

    03/21/2023, 6:37 PM
    I want to create complex object from GUI (React app) which includes some children objects. It means my complex object has ID and children has ROOT_ID that refers to my complex object ID. I want to do this as a single transaction - all or nothing. How to do this? I don't want to create a separate RPC methods for all such operations (I have many objects). So I'd pefer to use standard INSERT operations. However as I see TRANSACTIONS are not accessible from supabase client. How do deal with this?
    g
    • 2
    • 1
  • Should there be individual ruby gems for gotrue, realtime, storage, functions, libraries?
    s

    siva m

    03/21/2023, 6:45 PM
    should we start writing gems?
  • How would I get return a set of most recent items (based a column)?
    h

    hortinstein

    03/21/2023, 7:13 PM
    Lets say I have a table of phone calls and
    Copy code
    create table phone_calls (
      id uuid default uuid_generate_v4() primary key,
      owner_id uuid not null references auth.users(id) default auth.uid(),
      phone_number in,
      coord text,
      created_at timestamp default now()
    );
    and I wanted to query with a list of phone numbers and return only the most recent record for each phone number. I know I could do this by running a query for each phone number, but is it possible to only get the most recent for each in the list with a starter query like this?
    Copy code
    final data = await supabase
      .from('phone_calls')
      .select('id,coord')
      .in_('phone_number', ['4257771111', '4257771112']);
    I know I could parse them out after it returns, but I dont want to return all that data if not necessary and would be afraid it could grow past what I would reasonably think the client would handel.
    g
    • 2
    • 2
  • Can't connect
    t

    Tehker

    03/21/2023, 7:54 PM
    I get this error psql: error: connection to server at "database hosted by supabase", port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? I can't even connect through PgAdmin and have tried restarting the database too.
    j
    g
    • 3
    • 6
  • FetchError: Response constructor: Invalid response status code 204
    h

    homyak

    03/21/2023, 8:02 PM
    I have a Next 13.2 build with a route to delete an item. When I call
    supabase
    to delete the item as per the docs, the item is successfully deleted but it returns an error object. I am instantiating
    supabase
    via
    createServerComponentSupabaseClient
    from the
    @supabase/auth-helpers-nextjs
    library.
    Copy code
    json
    {
      message: 'FetchError: Response constructor: Invalid response status code 204',
      details: '',
      hint: '',
      code: ''
    }
    Copy code
    javascript
    const id = '9c16f914-8695-4dc5-b37e-bb54a45d32a8'
    const supabase = createClient()
    const { error } = await supabase.from('topics').delete().eq('id', id)
    
    if (error) {
       console.warn('[Error]', error)
    }
    g
    • 2
    • 33
  • Supabase Client Library V3.0 release date
    j

    Joseph96

    03/21/2023, 8:12 PM
    Hello, I had a quick question. When is JavaScript Client V3.0 coming out? A use case I wanted was that
    onAuthStateChange
    to work across tabs. Right now the docs say this.
    Currently, onAuthStateChange() does not work across tabs. For instance, in the case of a password reset flow, the original tab which requested for the password reset link will not receive the SIGNED_IN and PASSWORD_RECOVERY event when the user clicks on the link.
    This was important to me when working with a Expo-React-Native App I was working on when authentication happened when opening an in-app browser. I figured out a work around in the end. But, would be nice not to have a work around. Thanks!
    g
    • 2
    • 1
  • How can you set a timestampz cell to null in the dashboard?
    p

    Psygen

    03/21/2023, 8:36 PM
    All the other cell types have a "set to null" button. Not timestampz for some reason. Am I missing something?
    • 1
    • 1
  • Error: Failed to run sql query: column "__parsed_extra" of relation "[Table Name]" does not exist
    r

    RK

    03/21/2023, 8:44 PM
    Hi Everyone, I am trying to upload a csv file with 11mn rows. Supabase accepts the file and starts uploading but gives an error after about 180K rows. The error is in the headline. What should I do to prevent the error? Not assigning a primary key didn't help. Still got an error. RLS is turned on.
    n
    • 2
    • 1
  • what do i do when supabase doesnt send data my way ?
    g

    Grimmjoww231

    03/21/2023, 9:49 PM
    its that simple. i recieve an empty array and regardless of what i do RLS or NO RLS same empty array and all i have is 5 lines of code calling it. every query to supabase is documented on the site yet no data retrieved.
    g
    • 2
    • 1
  • How can I query this fk bridge table in supabase js?
    y

    yayza_

    03/21/2023, 10:32 PM

    https://i.imgur.com/iPKndRn.png▾

    I have this table called sku_attribute_values that links product_skus, attributes, and attribute_values tables I made all the foreign keys primary keys also as suggested by another post. I use the following query:
    Copy code
    js
        const selectQueryString = `
        *,
        category:categories(id,name),
        product_skus(*, sku_attribute_values(sav_id:id, attribute_values(value),  attributes(name)))
      `;
    Copy code
    js
            sku_attribute_values: [
              {
                sav_id: 146,
                attribute_values: { value: '12oz' },
                attributes: { name: 'Size' }
              },
              {
                sav_id: 147,
                attribute_values: { value: 'Strawberry' },
                attributes: { name: 'Flavor' }
              }
            ]
    but I was wondering how I can query this to get the data I need like this:
    Copy code
    js
            attributes: [
              {
                sav_id: 146,
                value: '12oz',
                name: 'Size' 
              },
              {
                sav_id: 147,
                value: 'Strawberry',
                name: 'Flavor' 
              }
            ]
    I tried to do it the other way around where I query attributes first, but then I get a relationship error and any of the hints provided in the error give me a many to many or one to many results (and i'm not very good on using hints) Would be nice to do it in in the supabase client but if I have to map through them in js that's fine, just wondering if i'm missing something i'm not aware of with the client
    g
    • 2
    • 7
  • Structure of Query does not match function result type
    m

    mansedan

    03/21/2023, 11:06 PM
    Hey all. We are setting up a function and I just can't seem to work out an error I was hoping someone here might be able to spot it. Here is our function creation:
    Copy code
    sql
    
    CREATE OR REPLACE FUNCTION test_pool(date_val DATE, type_val VARCHAR) 
    RETURNS TABLE (profile UUID, win_percentage NUMERIC, unit_profitability NUMERIC) AS $$
    DECLARE
      total_units_won NUMERIC;
      total_units_lost NUMERIC;
    BEGIN
        IF type_val = 'win_percentage' THEN 
          RETURN QUERY
          SELECT p.author AS profile, 
                 (CAST(COUNT(CASE WHEN p.pick_status = 'WIN' THEN 1 END) AS NUMERIC) 
                  / NULLIF(COUNT(CASE WHEN p.pick_status <> 'pending' THEN 1 END), 0)) 
                  * 100 AS win_percentage,
                 0 AS unit_profitability
          FROM posts p
          WHERE p.created_at BETWEEN date_val AND NOW()
          GROUP BY p.author
          ORDER BY win_percentage DESC;
    
        ELSIF type_val = 'unit_profitability' THEN
          RETURN QUERY
          SELECT p.author AS profile,
                 0 AS win_percentage,
                 COALESCE(SUM(CASE WHEN p.pick_status = 'WIN' THEN p.units_win ELSE 0 END), 0) 
                 - COALESCE(SUM(CASE WHEN p.pick_status = 'LOSS' THEN p.units_risked ELSE 0 END), 0) 
                 AS unit_profitability
          FROM posts p
          WHERE p.created_at BETWEEN date_val AND NOW()
          GROUP BY p.author
          ORDER BY unit_profitability DESC;
    
        ELSE
          RAISE EXCEPTION 'Invalid type value: %', type_val;
        END IF;
    
    END;
    $$
    LANGUAGE plpgsql;
    When running the queries individually, outside of this function, we get results like the attached screenshots. Can anyone sport what might be incorrect about our RETURNS TABLE statement?
    g
    • 2
    • 11
  • Must be owner of table X when trying to create an index via Python
    a

    Adobe.Flash

    03/21/2023, 11:20 PM
    Hi, im current facing an issue where I get the following message "Must be owner of table X" when trying to create an index (via Python) on a table that I created in the Supabase dashboard. Is there a way to give my Supabase python project admin permissions to be able to make a change like this? I want to be able to run my
    create_index
    function programatically. Thank you.
    o
    g
    • 3
    • 38
  • Auth UI: Google OAuth is working, but email is not
    s

    samuyoon195

    03/22/2023, 2:45 AM
    When a user signs in with Google, they are correctly redirected to http://localhost:3001/loginrouting/ as specified in the redirectTo field. However when the user logs in via email and pw, they are not redirected and remain on the http://localhost:3001/login/ page. I was able to confirm that the login request was successful when using email and pw. The only thing that is not working is the redirect. See screen recording here: https://www.loom.com/share/f32306a460ad4704b07f7ff0f6fb061b Email is enabled as an Auth Provider in my Supabase Authentication settings.
    k
    g
    • 3
    • 3
  • Allow users to toggle a page from public/private?
    m

    mlc

    03/22/2023, 3:28 AM
    I'm building a page that a user can toggle public vs. private. There's only 1 table that has a RLS. I'm trying to figure out how I'd do this. I don't see an example in the documentation that checks on the data to see if it can be selected rather than the user_id. given a page_id (page1) owned by user (user_id_7). If that user wanted the page to be public. how would I allow page_id: page1 to be selectable by anyone?
    n
    • 2
    • 1
  • Self hosting - email template
    i

    infinity

    03/22/2023, 5:15 AM
    How to edit email templates (confirmation, reset password…) in self host?
    ł
    • 2
    • 1
  • Collaborative Editor with Supabase Realtime
    h

    harshcut

    03/22/2023, 5:26 AM
    Is it possible to make collaborative codemirror editor with supabase realtime? If so, is there any example code that i can take a look at. I have already looked at y-supabase, but I couldn't get it to work.
  • Unable to redirect invited user
    s

    Sumit1993

    03/22/2023, 8:10 AM
    I am inviting a new user in my local env using supabase.auth.admin.inviteUserByEmail method and passing my dev env url for the redirectTo key .This is not working properly and redirecting user to my local env url. At the moment I am using the same project for the two envs and set up the local env SITEurl for url config... Is it because of that ? Can anyone help me resolve this issue fast?
    n
    • 2
    • 11
  • Local development: Nextjs server component. Supabase does not connect to localhost
    s

    shriharip

    03/22/2023, 9:04 AM
    Hello, Please requesting some help here. I have also opened an issue on the nextjs-auth helpers. For some reason on the server and the middleware the supabase is connected to the localhost. However the browser client is still connects to the production . I am passing the
    Copy code
    supabaseUrl, supabaseAnonKey'
    . The relevant git issue with more code https://github.com/supabase/auth-helpers/issues/476 Thanks
    n
    s
    • 3
    • 4
  • What's the state of Self Host Supabase?
    h

    Han

    03/22/2023, 9:11 AM
    Last year, I've been trying to set up a supabase locally to test the functionality it offers. As it turns out, there are features missing from supabase cloud like edge functions, storage, logs, backups, etc. I'm not sure if the self hosted supabase is meant to be a single instance or not.. but, from what i've seen ages ago.. it's only one instance per server. I've just come back to supabase after a long time developing apps for my final college project. Are there any improvements or additions I'm missing? What is the direction for self host development from supabase team pov? Thanks for reading this.
  • Supabase certificate issue? https problem using HTTP api
    m

    maks_k

    03/22/2023, 9:52 AM
    Hey, community! I'm new here so maybe this is a stupid question. I just decided to give Supabase a try and my first http call failed 🤷‍♂️ Looks like certificate issue of Supabase. Or did I miss something?
    s
    • 2
    • 3
  • [solved] CORS Error on local development with NextJS and Supabase
    k

    kobyisalegend

    03/22/2023, 10:13 AM
    heyho, I've a question regarding supabase local development CORS policy. My nextjs App is on localhost:3000 and supabase local docker container on localhost:5432X. Everytime I make a request for data, or try to use the signup functions i get a CORS related error:
    Copy code
    Access to fetch at 'http://localhost:54324/auth/v1/token?grant_type=password' from origin 'https://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
    And I really can't get my head around that, I don't find any documentation or help to get my request get trough on local development. If I use the DB directly from a supabase URL, f.ex.:
    https://xxx.supabase.co
    it works just fine. But i really want to operate directly on a local environment and not use the web application for my app at the moment. The request I make for example, to login is like that:
    Copy code
    supabase.auth.signInWithPassword({
      email: 'email@xyz.dev', 
      password: 'xyz1234',
    })
    Can somebody tell me what I do wrong here?
    s
    h
    • 3
    • 5
  • Not able to retrieve data (seems linked to RLS)
    m

    MusashiGarami

    03/22/2023, 11:00 AM
    I've tried this in my own app following supabase docs, reference next docs etc.(next 13 app dir + supabase). I couldn't get it to work. I created a new next app from scratch and followed this tutorial:

    https://www.youtube.com/watch?v=GniRj1jIhFw&t=440s&ab_channel=Supabase▾

    (Fetching and Caching data in Next.js Async Server Components) I've followed the code, and get the same as I had on my app. the call returns an empty array: import supabase from "@/utils/supabase"; export default async function Materials() { const { data } = await supabase.from("materials").select(); return {JSON.stringify(data, null, 2)}; } I've written the above in different ways, and still get same behaviour. It returns []. I have added RLS as per the video above and also tried RLS with a template, but same results. RLS is anyone can read posts, to public, expression is true. I have correct .env.local (I'm making api calls, and supabase is reporting the api calls) Would really appreciate some assistance. P.S Quite excited to start using supabase it looks epic.
    g
    b
    • 3
    • 62
  • stripe.customers.create and updating a table
    f

    filiphric

    03/22/2023, 11:03 AM
    Hey y’all! I’ve been following this nice tutorial on egghead.io https://egghead.io/lessons/supabase-automatically-create-a-stripe-customer-for-each-user-with-supabase-function-hooks and I have written a function that looks something like this:
    Copy code
    ts
    // eslint-disable-next-line @typescript-eslint/no-var-requires
    const stripe = require('stripe')(process.env.STRIPE_API_KEY)
    
    export default async (req: any, res: any) => {
      if (req.query.API_ROUTE_SECRET !== process.env.API_ROUTE_SECRET) {
        return res.status(401).send('You are not authorized to create a new user')
      }
    
      const customer = await stripe.customers.create({
        email: req.body.record.email
      })
    
      await supabase.from('profile').update({
        stripe_customer: customer.id
      }).eq('id', req.body.record.id)
    
      return res.send({ messgae: `stripe customer created hello ${customer.id}` })
    }
    I have created an ngrok tunnel (as tutorial suggests) and set up a webhook on supabase. the webhook seems to trigger properly as confirmed by couple of console logs. The odd thing is, that after the
    stripe.customers.create
    function runs, nothing else in the function above gets executed, again, tested by adding a bunch of console logs. when I call the api locally, both localhost and ngrok urls work fine and will add will properly update the
    profile
     table. maybe this is more of a js/ts question, but I’ve been trying to figure this out and could not find a doc or a resource that would guide me. any help appreciated.
    • 1
    • 1
  • Using Stripe with Supabase?
    t

    Trevvy

    03/22/2023, 11:20 AM
    I'm working on a Project, and I really do want to use Supabase - I want to to avoid having to manage my own server. A crucial part of my application is subscription payments, and one off payments from users. I have looked around regarding Stripe with Supabase, and it seems to rely on Webhooks. I'm not sure if webhooks are suitable for a case though. Most of these examples I've looked at, sends the user to a third party stripe page to handle the payment - my app will be processing the payments directly in the UI, before sending everything off to Stripe to handle. Eventually, I plan to add paypal as a payment option for subscription/one-off payments. I'm I going to run into trouble with Supabase? Can anyone recommend some resources for Stripe and Supabase, other than the video posted by Supabase regarding stripe webhooks
  • Using GraphQL independent of Supabase authentication
    m

    Muezz

    03/22/2023, 12:14 PM
    As far as I know, GraphQL, within Supabase, works out of the box with Row Level Security. Now if I have an app that does not use Supabase authentication (instead it uses some other provider), how would my RLS policies resolve wherever I use
    auth.uid()
    ?
    g
    • 2
    • 6
  • Difficulty of moving from Firebase -> Supabase?
    c

    Computer

    03/22/2023, 2:14 PM
    Things to keep in mind? Is this a good use case for GPT-4?
    s
    g
    • 3
    • 6
  • Learn to make queries
    s

    Saad

    03/22/2023, 2:25 PM
    Hi Everyone! I am Abu. I'm new to software dev with only a background in electrical engineering. I have recently begun an internship where I am building a job platform application using Appsmith as the frontend and I am using Supabase as the backend managing user login and creating granular access roles (hope I wrote that right). Could you please help me by sharing resources or where I could learn SQL querying or what should I be learning to be able to make RLS policies? For now, it seems that the templates given are not really getting my desired task done. So, I would like to write the queries myself. An example would be the following: The 1st image(from the top left side) is a table of all the job listings (for now I was trying to implement user roles and permissions so only 1 entry is there) on my application. The 2nd image is a table containing all the details of the registered users and their "roles". Now in the 1st table i.e. the "job_listings" table I only want: 1. authenticated AND 2. users with the role "recruiter" and "admin" (from the 2nd table i.e. the "users" table) AND 3. the user who made the job listing to only change his job details The other type of user role: "job_seeker" can only view. I tried using the template given for UPDATE (shown in the 3rd picture) for users based on email that is the RLS for the "job_listings" table to implement the 3 things I wanted. However, I do not know how I can include the "role" of those registered users from the other table and set up a logic + I do not understand really what's going on here even with the template + I do not know how I can only allow the "recruiter" user who is logged into my application to only change his job listing. The 4th pic shows how the API query is being performed in Appsmith.
  • How to run open ai fetch edge function (that return RedableStream) in parallel ?
    h

    hidfap

    03/22/2023, 2:35 PM
    Hello 🖐️ following this video :

    https://www.youtube.com/watch?v=9N66JBRLNYU▾

    and this code :
    Copy code
    import 'xhr_polyfill'
    import { serve } from 'std/server'
    import { CreateCompletionRequest } from 'openai'
    
    serve(async req => {
      if (req.method === 'OPTIONS') {
        return new Response('ok', {
          headers: {
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Headers':
              'authorization, x-client-info, apikey, content-type'
          }
        })
      }
      const { query } = await req.json()
    
      const completionConfig: CreateCompletionRequest = {
        model: 'text-davinci-003',
        prompt: query,
        max_tokens: 256,
        temperature: 0,
        stream: true
      }
    
      return fetch('https://api.openai.com/v1/completions', {
        method: 'POST',
        headers: {
          Authorization: `Bearer ${Deno.env.get('OPENAI_API_KEY')}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(completionConfig)
      })
    })
    these edge functions return a RedableStream fetch from openai my problem is that when i run the function once I cant run it again the second function is blocked until the first one is not completed how can i get two edge functions to work in parallel ? thanks for your time & work ❤️
    o
    g
    m
    • 4
    • 32
  • Can one project be used to keep multiple env (dev/prod) dbs?
    s

    Sumit1993

    03/22/2023, 2:56 PM
    Can i use one project to keep multiple env (dev/prod) dbs ?
    s
    t
    s
    • 4
    • 9
  • Nested foreign sort order is not working
    l

    Luke

    03/22/2023, 3:26 PM
    I found this GitHub issue that says this was resolved, but it's not working for me still. We are on Supabase-js 2.4.1 https://github.com/supabase/postgrest-js/issues/149 The property I want to sort by is many layers deep: jobs.properties.customers.account_name. So "account_name" goes into the sort_field, and "jobs.properties.customers" goes into the foreignTable. When I do this, I get no errors and the result does sort into a consistent order, but only one order - the sort_order makes no difference and the foreign table field I target makes no difference, it always sorts it in the same order every time. So it feels like it's partially working, but not entirely. Is there something I'm missing?
1...175176177...230Latest