https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Supabase realtime giving me channel error for postgres changes
    b

    bpeck81_

    03/02/2023, 4:00 PM
    Just started happening. Anyone else having this?
    m
    • 2
    • 3
  • Using OAuth in Chrome extension
    z

    zetiks

    03/02/2023, 4:53 PM
    I am trying to use OAuth in Chrome extension. Just calling
    .singInWithOauth()
    does not seem to do anything, I believe it might be due to extension security policies. So I assume I need to do this manually by calling
    .chrome.identity.launchWebAuthFlow()
    which I am doing and it successfully returns the tokens. Now, the question is how do I use those OAuth tokens (access, refresh) with Supabase JS library to actually sign the user in? I did found that in the
    v1
    of the library I could just do
    Copy code
    const { user, session, error } = await db.auth.signIn({
        refreshToken
      });
    But in the newest version of the library there is no
    db.auth.signIn()
    . Even though here: https://supabase.com/docs/learn/auth-deep-dive/auth-deep-dive-jwts it is mentioned once. I couldn't find much more in the documentation and when Google just returns results from
    v1
    . How is it handled currently?
    j
    • 2
    • 2
  • database queries on localhost are really slow
    j

    JoshTheNerd

    03/02/2023, 5:14 PM
    On localhost my db queries using the postgres connection string are really slow. I don't get this issue when this nextjs project is on prod (somewhere in newyork)
    n
    s
    r
    • 4
    • 116
  • Session and user
    j

    Joey9

    03/02/2023, 5:33 PM
    I see that user is inside the session. So do we need to save the user too? or can just save the session and access the user from there?
    n
    g
    • 3
    • 34
  • Get user details by id
    r

    Revaycolizer

    03/02/2023, 7:24 PM
    Tried to get user by ID by saying I'd not defined anyone having an idea
    Copy code
    const getById = async (table, id) => {
        const { data, error } = await supabase
          .from(table)
          .select("*")
          .eq('id', id);
        if (error) throw error;
        return data[0];
    }
    g
    s
    • 3
    • 12
  • order by in RPC
    n

    nimo

    03/02/2023, 7:33 PM
    I have an RPC call in my react app that returns an array of
    id "uuid", match record
    . I'd like to order the result by one of the fields in the match column. Is it possible to do that? I am getting an error trying to run:
    Copy code
    const { data: documents, error: rpcError } = await supabase
      .rpc('...', { QUERY_PARAMS })
      .select('*')
      .order('match.similarity')
      .limit(max_count);
  • Local DB stuck at loading "Connecting to Default project"
    d

    desiboli

    03/02/2023, 7:46 PM
    I have docker running and ran the `supabase start`command to start the container. The container is running fine and I see all the Supabase local development setup links. When I go to the Supabase Studio url at: http://localhost:54323 the db doesn't seem to be able to connect. In the browser console I see the following: Request URL: http://localhost:54323/api/projects/default/api/rest Status Code: 404 Not Found I do have the DATABASE_URL in .env file:
    DATABASE_URL="postgresql://postgres:postgres@localhost:54322/postgres"
    What could be the issue here? Thanks for helping me 🙏
    r
    s
    • 3
    • 16
  • Database hook for when the value of a specific column in a certain table changes
    p

    pakkerr

    03/02/2023, 8:09 PM
    I basically want to send an email to a user when the value of a column titled ''verification_status'' changes from 'pending' to 'approved'. If this is not possible to do, I may just have to build an admin only page and then add this send email operation to a task queue if the update operation is successful.
    s
    • 2
    • 3
  • Help with foreign key joins (when multiple tables share key) using JS API.
    k

    Kevin W

    03/02/2023, 9:07 PM
    I get the following foreign key error when attempting to get a complete "theme" from my database like this:
    Copy code
    js
    db.from('themes')
      .select('*, snippets (*), users (*)')
    Error:
    Could not embed because more than one relationship was found for 'themes' and 'users'
    If I remove the
    users
    join, it works fine. Obviously it's not sure whether to join
    user_id
    from the original theme table, or perhaps the joined snippets table. Is there some way to specify which foreign key/table to join from? Here's a simplified table structure (all appropriately foreign keyed): themes: id user_id users: id snippets: id user_id themes_snippets (join table) theme_id snippet_id
    g
    • 2
    • 4
  • Supabase Subscription + Clerk.dev
    m

    mlc

    03/02/2023, 9:59 PM
    My subscription is only seeing Deletions. It seems like theres an bug with my RLS. I'm using Clerk.dev with their JWT. Once I turn off my RLS everything works as intended. The only RLS I have is the suggested selection one
    (requesting_user_id() = user_id)
    g
    b
    • 3
    • 15
  • Why is auth.uid() returning 'null' in SQL Editor?
    b

    Bizzare

    03/02/2023, 10:05 PM
    If I'm using the SQL Editor and I write 'select auth.uid();' I get a null value in the resulting table... why is that happening?
    g
    b
    • 3
    • 3
  • Can I use supabase/postgres db as a normal postgres db?
    c

    Chiggy

    03/02/2023, 10:54 PM
    Hi there. I am looking into deploying supabase using docker. I also have another service to depoy, huginn, which needs a plain ol' postgres db. So my question is, can I just deploy the docker compose that comes with supabase/postgres, then login into it and create a new db for huginn, and call it a day? Or is it different from regular postgres?
    o
    • 2
    • 7
  • typescript
    j

    Joey9

    03/03/2023, 12:16 AM
    is this how one would type stuff? i generated the types already
    Copy code
    tsx
    type Profiles = Database['public']['Tables']['profiles']['Row'];
    type UserProfile = Omit<Profiles, 'updated_at' | 'created_at'>;
    b
    u
    • 3
    • 2
  • How to run edge function locally and hot reload
    m

    MahdiWidian

    03/03/2023, 2:08 AM
    Hi, i want run edge function in local because i need debug it with console and want to trace the flow, then i already run supabase with "npx supabase start" and start edge function locally with "npx supabase functions serve hellow-world" it has already listen:8000 but when i have changes in my codes it's not trigger the hot reload, I doubt this step is correct or not to run edge function in local, any solution?
    s
    s
    • 3
    • 3
  • Foreign Key with an array of uuid's?
    u

    49Ryann

    03/03/2023, 3:05 AM
    I have a table that reflects active Twilio conversations in where I'd like to store an array of users that are participants in each conversation, this allows the web app to display the correct data of each participant in the conversation on the frontend. Currently I just allow a single user to be in the conversation with a single contact stored 'user_id' & 'contact_id'. But preferably I'd want multiple users, 'user_ids' as array. Generally there would be around 1 or 2 users in a conversation with one contact (Always single contact) & at max there would say up to 10 users so It seems not worth creating another table 'conversation_participants' to handle this situation, considering all that the frontend needs is the user data available in the array to map and display. I tried last night but with not much luck, it seems like I'd have to store an array of UUID's and then use an rpc function to get the conversation then joining the user_ids array data, Is this the case? Other opinions welcome. Doesn't seem like there is a way to populate this from the javascript package, Array documentation doesn't seem that well documented if there is more features. Ryann,
    g
    • 2
    • 3
  • Console.log doesn't work in edge functions
    l

    lecookie

    03/03/2023, 4:15 AM
    console.log used to work like an hour ago but know it doesn't here is my code
    Copy code
    js
    // Follow this setup guide to integrate the Deno language server with your editor:
    // https://deno.land/manual/getting_started/setup_your_environment
    // This enables autocomplete, go to definition, etc.
    
    import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
    import { createClient } from "https://esm.sh/@supabase/supabase-js@2";
    import corsHeaders from "./_shared/cors.ts";
    
    serve(async (req) => {
      console.log(req)
      try {
        const supabase = createClient(
          // Supabase API URL - env var exported by default.
          Deno.env.get('SECRETSUPABASELINK') ?? '',
          // Supabase API ANON KEY - env var exported by default.
          Deno.env.get('SECRETSUPABASEKEY') ?? '',
          // Create client with Auth context of the user that called the function.
          // This way your row-level-security (RLS) policies are applied.
          { global: { headers: { Authorization: req.headers.get('Authorization')! } } }
        )
      } catch(e) => console.log(e)
      const { option } = await req.json();
      console.log(option)
      let data = "no option provided";
    
      if (option == "server") {
        console.log('token')
        const token =
          Deno.env.get('BOTOKEN')
        const headers = {
          ...corsHeaders,
          Authorization: token,
          "Content-Type": "application/json",
        };
        if ((await req.json().option) == "server") {
          const res = await fetch(
            "https://discord.com/api/guilds/1068721953185206354/preview",
            {
              headers: headers,
            }
          );
          data = await res.json();
        }
        return new Response(JSON.stringify(data), {
          headers: headers,
        });
      } else if (option === "kick") {
        console.log('kick')
        const {data,error} = await supabase.from('publicprofile').select()
        console.log(data)
      }
    });
    u
    • 2
    • 25
  • Will auth.uid() return the caller for a Security definer function?
    d

    DanMossa

    03/03/2023, 6:56 AM
    If I create a function as Security Definer, will using auth.uid() return the invoker's or definer's uid?
    n
    s
    • 3
    • 3
  • Best way to delete all rows from a table using supabase.js?
    l

    lake_mattiato

    03/03/2023, 8:14 AM
    Looking to delete everything from a table, doing it row by row seems... inefficient?
    n
    • 2
    • 2
  • SupabaseJS: Is there a transactions interface on the roadmap?
    o

    ostoto

    03/03/2023, 8:22 AM
    I'm looking to run updates within transactions at various isolation levels.
    s
    • 2
    • 1
  • supabase auth for a financial product
    s

    skopd

    03/03/2023, 9:21 AM
    would supabase auth meet all the regulations / compliance features needed if used for a financial product ? thanks !
  • Is there a way to export existing tables, relationships and triggers to postgres statements?
    l

    lake_mattiato

    03/03/2023, 9:37 AM
    I was wondering if it is possible to export all tables so i can update the ER diagram.
    s
    • 2
    • 1
  • Deleting a row from auth.users with rpc
    e

    elliott

    03/03/2023, 9:45 AM
    How do I delete a row from auth.users with rpc? I have all of my cascades set up, and am able to successfully delete a row from users using the UI in supabase, but when I try to do it from an rpc function I get an error: "permission denied for table users". Thank you.
    s
    • 2
    • 1
  • Could supabase database webhooks handle 30-40 new rows inserted at once?
    l

    lake_mattiato

    03/03/2023, 10:28 AM
    For each inserted row an api call would be made and would store the result in a column inside that row
    g
    • 2
    • 1
  • Updating multiple columns with WHERE
    s

    ShaneJones

    03/03/2023, 11:10 AM
    I think I'm getting lost in some of the chaining here with the React API Essentially some of this works on its own but not all together. What I'm trying to do is update bookings which have a status of 2 and an expired date with 2 new values in the update function
    Copy code
    const clearPendingRecords = await supabase
        .from('bookings')
        .update({'booking_status': 4})
        .update({'hold_until': null})
        .eq('booking_status', 2) 
        .lt('hold_until', Date.now())
    Is the ordering incorrect here or am I miles off on this?
    g
    • 2
    • 4
  • Edge functions setup
    b

    bekathegooner

    03/03/2023, 11:25 AM
    Hi, I'd like to setup supabase locally and learn the architecture. Could you please explain where is this function store in the architecture diagram? How does Supabase save Edge function metadata in this function store. (where in the source code)
  • Invalid login credentials but postman is fine
    d

    donbwhite

    03/03/2023, 1:38 PM
    New with supabase and testing out using the built in functionality but having some difficulty with the auth. When I send in to the /auth/v1/token?grant_type=password via the browser/app I get an error response
    Copy code
    error: "invalid_grant"
    error_description: "Invalid login credentials"
    But if I send the same request, apikey, via PostMan it works as expected and returns the user. Has anyone encountered anything like that before? The email is validated an verified in both the supabase ui and confirmed that it works in PostMan.
    • 1
    • 1
  • Handling admin tasks like creating users and adding data to users
    v

    Vimes

    03/03/2023, 2:28 PM
    Setting up Supabase auth with NextJS. Each user has access to X objects in the database through RLS, so they can only see what is connected to their user. But I also want admin users who can do pretty much anything, like create and delete users while adding data about those users in other tables. How should this best be done? I access supabase using const supabase = createServerSupabaseClient(ctx); that pulls my anon key and url. One solution could be tho check if a user has certain things met, then they can query data from the /api folder using service key. but this seems cumbersome. I want my admin users to be able to use access all logged inn pages for everyone. Then I'd have to create two ways of loading all data, one for "normal" users with getServerSideProps and one for admins with /api.
  • Can't send mail with SMTP in deno supabase edge function
    f

    FilippoBrigati

    03/03/2023, 3:25 PM
    Hi, I'm trying to import the "SMTP deno" package into a supabase edge function, but it keeps giving me import errors such as worker thread panicked TypeError: Cannot read properties of undefined (reading 'UnexpectedEof') at https://deno.land/std@0.81.0/io/bufio.ts:22:51 I also tried to use the denomailer library, also by deno, but I still get the same type of errors. Someone can help me?
  • Trying to ensure a user only accessed their data
    a

    Amara

    03/03/2023, 4:52 PM
    I created a nextjs application using supabase but now i want to make sure that a user only accesses their own data, right everybody accessess everything and it’s very dangerous. I have tried to check out the documentation but i don’t really get it
    n
    g
    • 3
    • 87
  • How to modify "raw_app_meta_data" from external?
    o

    oldwired

    03/03/2023, 5:10 PM
    I try to build a new platform based on supabase that integrates legacy systems. I want to also use supabase auth in some legacy systems. For this I need some information in the jwt and I figured adding this information to "raw_app_meta_data" is best. But this data needs to be added from one of the legacy systems via DB access, because this system "has the data" (and is best suited for the "calculations". I created a new postgresql user "legacyuser" for my legacy system, I even gave that user "superuser" and "bypassrls" privileges. But I still can't edit the auth.users table. I tried to give the user GRANT ALL ON table auth.users TO legacyuser; But I can only read, but not change the data in auth.users.
    • 1
    • 1
1...152153154...230Latest