https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Performing an update in supabasejs v2 'is not assignable to parameter of type never'
    b

    Bonteq

    10/28/2022, 9:04 PM
    I'm trying to perform a
    .update
    using the following code
    Copy code
    const { error } = await supabase
          .from('videos')
          .update({ current_time: currentTime })
          .eq('user', user.value.id)
    and it is giving me the error
    Argument of type '{ current_time: number; }' is not assignable to parameter of type 'never'.ts(2345)
    What is the appropriate solution to this?
    s
    a
    • 3
    • 3
  • Creating a policy which links to another table
    s

    Sarcodo

    10/28/2022, 9:05 PM
    I have a link table which doesn't have a user_id column but links to a table which does. How can I write a policy which does a link to the table which has a user_id to be able to use
    uid() = myLinkTable.user_id
    ?
    g
    • 2
    • 1
  • Is there a way to run a select query linking a table and a view?
    s

    Sarcodo

    10/28/2022, 9:38 PM
    I have a view which is based on "table_2" which has a foreign key to "table_1" is there a way I can run a select query to join them from react? Trying to run:
    Copy code
    await supabase.from("table_1").select(
      id,
      ...columns,
      table_2 (
        table_2_id_col
        ...columns
      )
    )
    However I get an error "could not establish a relationship between table_1 and table_2". Looking at this page: https://supabase.com/blog/postgresql-views it says that a view behaves like a typical table and you can join with it and stuff, but maybe that's only backend joins rather than through the select function in js?
    g
    j
    • 3
    • 7
  • Pro Subscriptions not tied to a project?
    z

    ZaDeR47

    10/28/2022, 9:53 PM
    Hey folks, was looking at upgrading to the Pro plan on Supabase, with the goal of unlocking access to more than 2 projects. (I'd like to make more content around Supabase, and would like to have access to create many projects for examples) It looks like subscriptions are not tied to accounts, but rather to projects. Is there any options available now (or any plans in the future) to allow for paid "developer" accounts that allow for more projects without paying monthly per project?
  • RLS delete check based on auth.users.meta_data?
    u

    ((()))

    10/28/2022, 11:10 PM
    Each of my users get a metadata on creation either role=default or role=admin as seen in screenshot. How could I create an UPDATE/DELETE policy for role=admin on top of current policies similar to auth.id() = user_id?. I would like anyone with metadata.role == admin be able to update/delete any rows that they didn't create
    g
    • 2
    • 5
  • auto generate full text index doesn't generate if a Null is present
    l

    Liam Smith

    10/29/2022, 3:37 AM
    Is it normal for a generated index to not generate if there is a Null in one of the fields selected to be part of the index? If I put something in all the fields the index generates immediately; if I remove text from the field so it says 'EMPTY' rather than 'NULL' it also generates. Just trying to confirm this is expected so I can decide on the structure. Index code: alter table book add column fts tsvector generated always as (to_tsvector('english', title || ' ' || series || ' ' || "ISBN" )) stored; create index book_fts on book using gin (fts); -- generate the index select id, fts from book;
  • When seeding auth.users in local dev I get `function gen_salt(unknown) does not exist`
    c

    corasan

    10/29/2022, 3:55 AM
    Like the title says, I am trying to seed users in my local dev environment, which was working until I upgraded to the latest version of the CLI. I also should mention that pgcrypto is in fact added in the extensions. Is anyone else running into this?
  • Get user server-side on supabase js 2.0 + next.js
    u

    매튜

    10/29/2022, 6:51 AM
    Copy code
    export const getServerSideProps = withPageAuth({
      redirectTo: '/',
      async getServerSideProps(ctx, supabase) {
        //const { user } = await getUser(ctx);
        // Find out how many words user is currently studying at novice level - maximum allowed is 200
        const { data } = await supabase
          .from('users_vocabulary')
          .select('*', { count: 'exact' })
          //.eq('B', user.id);
        return { props: { data } };
      }
    });
    The above code worked on the old version of supabase js, but I had to comment out the user selection to make it work on the new version. What is the new equivalent of
    Copy code
    const { user } = await getUser(ctx);
    ?
    • 1
    • 1
  • How to enable database webhooks for local development
    o

    osener

    10/29/2022, 10:07 AM
    I want to use database webhooks by first implementing it in my local development environment. I can access the UI to create a webhook at http://localhost:54323/project/default/database/hooks but it fails with the error
    Failed to create hook: schema "supabase_functions" does not exist
    when I try to create the webhook. Is there a way to develop locally when using this feature?
    m
    h
    • 3
    • 3
  • do i still need to do all these steps to add increment function?
    t

    Thoth Trismegistus

    10/29/2022, 5:09 PM
    like it says in the comment
  • rpc method expects never type instead of string
    t

    Thoth Trismegistus

    10/29/2022, 5:17 PM
    Argument of type 'string' is not assignable to parameter of type 'never'
    a
    • 2
    • 5
  • list all auth.users
    u

    ((()))

    10/29/2022, 9:12 PM
    is it possible to list all auth.users meta_data without creating public.users as to not have redundant table that serves no real purpose?
    g
    s
    • 3
    • 6
  • Supabase Session Management
    b

    Bibek

    10/30/2022, 3:06 AM
    I was wondering if session management is possible with supabase in any way. My requirements is to allow users to keep track of their logged-in devices and allow them to revoke specific sessions (devices) or all of them. I have attached a sample screenshot to make my question more clear. Thank you.
    f
    n
    • 3
    • 18
  • Built-in way to cache images in GH Actions?
    z

    ZaDeR47

    10/30/2022, 4:12 AM
    Looks like a bottleneck in my CI/CD agents in Github actions with pulling the Supabase images. Is there anyway to cache these? (Currently adding the
    supabase
    npm package to install the supabase commands)
    • 1
    • 1
  • RPC function not working but no error is returned.
    f

    floyare

    10/30/2022, 12:43 PM
    So I have my RPC function in supabase Database Functions. It was working at the first time but now for some reason it stopped working. My function have
    row_id integer
    argument:
    Copy code
    update images
      set likes = likes + 1
      where id = row_id;
    and this is my js to run it:
    Copy code
    await supabase.rpc('increment', {row_id: id}).then(async (res) => 
      {
        //do stuff...
      })
    Response of this rpc have no error or any specific data. Any ideas?
    j
    g
    • 3
    • 45
  • Using withPageAuth without a session
    k

    Karbust

    10/30/2022, 4:00 PM
    Hello, I'm making a page where I want to access public data and at the same time private data related to the current logged in user (if there is any). This is my code:
    Copy code
    ts
    export const getServerSideProps = withPageAuth<Database>({
        authRequired: false,
        async getServerSideProps(ctx, supabase) {
            try {
                const { id } = ctx.query
    
                const response = await supabase
                    .from('Videos')
                    .select(`
                        title,
                        description,
                        likes,
                        dislikes,
                        views,
                        created_at,
                        VideoLikes (
                            type
                        ),
                        Profiles (
                            username,
                            profile_picture_url
                        ),
                        Servers (
                            id,
                            name
                        )
                    `)
                    .eq('id', id)
                    .limit(1)
                    .single()
    
                return {
                    props: {
                        video: response.data,
                        userRating: response.data?.VideoLikes && response.data.VideoLikes[0] ? response.data.VideoLikes[0]['type'] : 0
                    }
                }
            } catch (error) {
                console.error(error)
                return { notFound: true }
            }
        },
    })
    It works without any issues when there's a logged user, but when there's no user logged in it throws that error. The code from the supabase query is being executed correctly Any idea on how to solve it? Thank you `next`: 12.3.1 `@supabase/supabase-js`: 2.0.4 `@supabase/auth-helpers-nextjs`: 0.4.2
    g
    n
    • 3
    • 12
  • `column path_tokens of relation objects already exists` on Storage
    s

    siah

    10/31/2022, 8:00 AM
    We're getting a recurring
    column "path_tokens" of relation "objects" already exists
    error on the Storage logs, and are unable to upload to or retrieve from storage. This happened after we migrated from an existing project to a new one. Happening on a day we're going to production so would really appreciate any help here! 🙏
    g
    • 2
    • 6
  • supabase-js v2 runtime error with SvelteKit
    k

    Kasper

    10/31/2022, 8:56 AM
    Anyone have any idea how to fix this runtime error coming from
    PostgrestBuilder.ts
    ?
    Copy code
    Uncaught SyntaxError: The requested module '/node_modules/cross-fetch/dist/browser-ponyfill.js?v=e020469d' does not provide an export named 'default'
    s
    g
    • 3
    • 11
  • Row level security; data returns null with join query
    d

    dhatGuy

    10/31/2022, 2:45 PM
    I have RLS on order and user table. And I fetch the orders as a cafe owner using
    Copy code
    const { data, error } = await supabaseClient
          .from("order")
          .select(`*, items:order_item(*), user(*)`);
    The user property always return null but when I disable RLS on user table, I get the user data
    g
    • 2
    • 50
  • Realtime subscription stopped working
    j

    Jeremy Deceuster

    10/31/2022, 3:27 PM
    The realtime subscriptions of my project suddenly stopped working today. Is the realtime service down?
    g
    • 2
    • 21
  • Query foreign tables between a post and a user
    i

    ismael1234

    10/31/2022, 3:27 PM
    I have a posts table connected to the user who created it through uuid. How can I select posts and also get user information? I have something like this: const test = await subase.from("posts").select(
    Copy code
    *,
         users(
           username
         )
    ); but it always returns the message "Could not find a relationship between 'posts' and 'users' in the schema cache". How can I retrieve user data from posts table?
    g
    j
    • 3
    • 17
  • Auth has done, but new row violates RLS for table
    i

    Ivan Kartashov

    10/31/2022, 3:50 PM
    https://github.com/supabase-community/supabase-py
    s
    • 2
    • 1
  • nextjs + supabase auth, how to persist user session?
    d

    Domcario

    10/31/2022, 4:44 PM
    new to supabase, just finished the 'basic setup' section from the docs https://supabase.com/docs/guides/auth/auth-helpers/nextjs. not sure where to go from here? when a user signs in on localhost:3000/signin, the supabase.auth.getSession() and .getUser() return values correctly, but if i go to localhost:3000/dashboard (after signing in), the user and session data is not persisted this is my _app.js
    Copy code
    js
    import '../styles/globals.css'
    import { createBrowserSupabaseClient } from '@supabase/auth-helpers-nextjs'
    import { SessionContextProvider } from '@supabase/auth-helpers-react'
    import { useRouter } from 'next/router'
    import { useState } from 'react'
    
    function MyApp({ Component, pageProps }) {
      const router = useRouter()
      const [supabaseClient] = useState(() => createBrowserSupabaseClient())
    
      return (
        <SessionContextProvider
          supabaseClient={supabaseClient}
          initialSession={pageProps.initialSession}>
          <Component {...pageProps} />
        </SessionContextProvider>
      )
    }
    
    export default MyApp
    j
    n
    • 3
    • 15
  • Foreign key on timezone with current utc offset
    p

    psteinroe

    10/31/2022, 5:23 PM
    We have a table timezones which is essentially a copy of the pg_timezone_names view. After the world changed the clocks past weekend, the utc_offset in our table is not correct anymore. Since the pg_timezone_names view is just a view, we cannot reference it. Ofc one option would be a cron job that runs twice a year and refreshes the copy. Is there any way to just reference a pg-provided table that contains the tz name with its current utc_offset instead?
    • 1
    • 1
  • Are there any downsides to turning off email confirmation before signing in?
    c

    Cheqo

    10/31/2022, 5:26 PM
    I am planning to run social media ads to my web app and I am trying to find most frictionless sign up experience so that I can capture most of the leads, my flow would be something like this. 1. User clicks on the ad. 2. Goes to the landing page. 3. Clicks "Get Started" button. 4. Goes to signin page, enters their credentials 5. Receives a multi step form to complete their profile (age, interests, etc.) Of course I want as much of my ad traffic to complete the whole flow, and I decided that turning off email confirmation would increase conversions. Are there any downsides to this or can this be skipped at a later stage? In general why would someone use emails that are not their own?
    j
    • 2
    • 5
  • Can a tigger work with storage
    r

    rlee128

    10/31/2022, 5:54 PM
    Are we able to create a trigger function that interacts with storage as well as auth?
    g
    • 2
    • 2
  • Webhook stops working out of no where
    v

    Vogelbert

    10/31/2022, 6:01 PM
    I have created this webhook which should fire when something is inserted into the profiles table. But at some point this webhook just stopped triggering at all. I have found a bug which related to this, but that should have been fixed a few months ago. Anything I am over looking?
  • Sending an email with row data when new row is added
    d

    Drew

    10/31/2022, 6:10 PM
    Users in my app can add a partner's email address, which is stored in a 'partner' table. Every time a new row is added to the partner table, I want to trigger an email to that partner letting them know they've been added (and giving them a chance to opt out). What's the best way to go about this? So far, I've tried using a Database Webhook with SendGrid, but I don't think those allow me to tailor the http request according to the new row data.
    g
    d
    • 3
    • 4
  • Only INSERT if reservation doesn't exist yet.
    u

    Unknown Member

    10/31/2022, 6:49 PM
    Hey guys, I am doing a policy to prevent a user from "double" booking a listing, and I am wondering if the following WITH CHECK is valid or if it's efficient. Conditions = Check if the authenticated user
    reserved_by
    already booked the existing
    listing_id
    Copy code
    WITH CHECK (auth.uid() = reserved_by 
    AND NOT EXISTS 
        ( select 1 from reservations where       
    listing_created_by = listing_created_by));
    d
    • 2
    • 9
  • NetworkError on every pages
    n

    Nakatox

    10/31/2022, 9:17 PM
    Hi ! I get this message on every page of my project. I tried to login/logout, leave the page/reload etc. but nothing changed. Ty 🙂
    g
    • 2
    • 14
1...565758...230Latest