https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Can anyone see whats wrong with my postgrest query? Trying to get all rows based on timestampz
    l

    lewisd

    09/26/2022, 1:35 PM
    Copy code
    const { data } = await supabase.from<SbConversation>(CONVERSATIONS_VIEW)
          .select("*")
          .match({
            userId: currentUser.id,
          })
    .or("lastRead.gt.latestMessage->>createdAt");
    I get the response:
    invalid input syntax for type timestamp with time zone: \"latestMessage->>createdAt\"
    It seems to be selected
    createdAt
    which is nested inside a
    jsonb
    object, since it knows it is a
    timestamp with time zone
    . Perhaps there's something wrong with using
    .gt
    ?
    m
    s
    • 3
    • 3
  • Timeout Error when deploying function
    j

    Jim

    09/26/2022, 1:42 PM
    Whenever I go to deploy a function using supabase I get the following error which stalls my CLI (it also breaks my OS and have to do a hard reset).
    Copy code
    Error: Get "https://github.com/denoland/deno/releases/latest/download/deno-aarch64-apple-darwin.zip": dial tcp: lookup github.com: i/o timeout
    • 1
    • 7
  • Auth UI not allowing to set cookie as httpOnly?
    m

    Migu

    09/26/2022, 2:05 PM
    With the release of the v2 JS client and the depreciation of setAuth, I'm currently trying to use the
    auth-ui-react
    UI component coupled with
    supabase-js@RC
    and I noticed that the cookie created is only
    secure
    and not
    httpOnly
    . Should I be worried about that? Is the only other solution to manually create the cookie server-side with the flag on and send it to the client? Given that setAuth is no longer available, how would I check if user is valid?
  • How to know if a user is logged in or no?
    m

    MrGandalfAndhi

    09/26/2022, 3:28 PM
    Supposing you mean in a client context ie the browser and whether the user themself is logged in, you can check for the supabase-client .auth.session(), if it is not null the user is logged in. In the v2 rc this is now auth.getSession().
    g
    • 2
    • 1
  • Supabase UI Self-Hosting
    a

    AllYourSupabase

    09/26/2022, 3:26 PM
    When self-hosting your own Supabase instance is it the same UI as offered on
    https://app.supabase.com/
    ?
    s
    j
    • 3
    • 3
  • supabase v2 - type returned is undefined[] | undefined
    m

    Miguel Espinoza

    09/26/2022, 3:35 PM
    I'm sure I'm missing something here. I'm using supabase-v2 and loaded Database types using the cli tool. I'm initializing the supabase client like so:
    createClient<Database>
    But the data returned is of type
    undefined[] | undefined
    . I'm on supabase-js 2.0.0-rc.10.
    • 1
    • 6
  • Supabase SvelteKit Helper
    b

    BoogersLLC

    09/26/2022, 3:48 PM
    I'm relatively new to both Supabase and Svelte Kit. I see there is an Auth Helper for Suapbase with SvelteKit (https://supabase.com/docs/guides/auth/auth-helpers/sveltekit). Maybe I'm just missing something but is this documentation out of date? There are naming conventions and stores in the example that I don't see anywhere else and aren't available such as: -
    import { session } from '$app/stores'
    -
    __layout.svelte.ts
    -
    hooks.ts
    instead of
    hooks.server.ts
    -
    import type { GetSession } from '@sveltejs/kit'
    s
    • 2
    • 3
  • Automatically add user email to a table on user signup.
    t

    The Little Cousin

    09/26/2022, 5:03 PM
    Is it possible to automatically add the user email to another table upon user creation? I need to have a User table with all users information, where this user info's is only manageable by the authenticated user, so the authenticated user can only read and update this specific row.
    m
    o
    • 3
    • 10
  • Supabase Functions set context for requesting user
    c

    ccssmnn

    09/26/2022, 5:32 PM
    Hey, I'm implementing a Supabase Function (Deno) using
    supabase-js v2
    on both client and server. I can create the client with the
    ANON_KEY
    , receive the user with
    client.auth.getUser(bearer-token)
    but I fail to set the client context for this user. I need this to have RLS applied to my database calls. How can I create the supabase client on the server on behalf of the user?
    supabase.functions.invoke(...)
    does not send any cookies, using the authorization header in
    createClient(...)
    does not work.
    g
    • 2
    • 1
  • how can I pass an array of objects to an rpc call?
    x

    Xzight

    09/26/2022, 5:33 PM
    For example something like
    Copy code
    js
    const { data, error } = await supabase
      .rpc('add_task_with_tags', { tags: [{owner_id: 1, title: "tag1"}] })
    m
    • 2
    • 6
  • Supabase realtime broadcasting slow and skipping some broadcasts
    d

    drunken_warrior

    09/26/2022, 5:49 PM
    I'm sending multiple broadcasts per second and every 1 out of 5 broadcast gets skipped randomly , I'm using the paid version. Do I need to configure anything?
    g
    • 2
    • 1
  • Better to use new table or JSON column?
    c

    Cory

    09/26/2022, 6:27 PM
    I want to add a place for my user settings, and account settings. Is it better practice to create a separate table for this, called something like, "user_settings" and "account_settings" or is it better to just use a JSON column and insert the settings into a "users" public table that I already have.
    s
    • 2
    • 1
  • Basic query works in V1 but not in V2
    g

    galizar

    09/26/2022, 7:07 PM
    I am trying to migrate to V2 and I realized the queries were not working at all with V2, so I set up this two test functions: V1:
    Copy code
    type group = Database['public']['Tables']['groups']['Row'];
    
    const supabase = createClient(url, anonKey);
    
    const propColumns = 'name, isTrashed:is_trashed';
    
    (async () => {
        await supabase.auth.signIn({email, password});
    
        const props = 
            await supabase
                .from<group>('groups')
                .select(propColumns);
    
        console.log(props);
    
    })();
    V2:
    Copy code
    const supabase = createClient<Database>(url, anonKey);
    
    const propColumns = 'name, isTrashed:is_trashed';
    
    (async () => {
        await supabase.auth.signInWithPassword({email, password});
    
        const props = 
            await supabase
                .from('groups')
                .select(propColumns);
    
        console.log(props);
    })();
    And indeed, the V1 version works as expected, but the V2 one does not return the correct data, it's
    undefined
    I've taken a look at the logs in the app page and there's this key difference in there: V1:
    Copy code
    "sb": [
        {
          "auth_user": "e92a8280-9d20-4dd9-9c0f-40c441810c41"
        }
      ],
      "search": "?select=name%2CisTrashed%3Ais_trashed",
      "url": "https://app url/rest/v1/groups?select=name%2CisTrashed%3Ais_trashed"
    V2:
    Copy code
    "sb": [],
      "search": "?select=name%2CisTrashed%3Ais_trashed",
      "url": "https://app url/rest/v1/groups?select=name%2CisTrashed%3Ais_trashed"
    It seems like the client isn't authenticated with V2, so RLS is doing its job. Is there something I'm missing regarding
    signInWithPassword
    ? The way it is talked about in the release notes sounds like it should be a swap in replacement and a quick look at the source seems to confirm that it does basically the same thing as v1's
    signIn
    . Would greatly appreciate any pointers
    • 1
    • 1
  • My view is returning duplicates even though I am joining using array_agg
    l

    lewisd

    09/26/2022, 7:44 PM
    Here is my view:
    Copy code
    select l.*, 
    "sellerData"."sellerData", "listingLikes"."listingLikes", "lineItems"."lineItems", "listingComments"."listingComments"
    from listings l
    
    left join ( 
    select id, 
    row_to_json(ud.*) as "sellerData" 
    from "userData" ud 
    group by ud.id 
    ) 
    "sellerData" on "sellerData".id = l."sellerId"
    
    left join ( 
    select "userId", 
    "listingId", 
    array_agg(jsonb_build_object('id', ud.id, 'username', 
    ud.username, 'avatar', ud.avatar)) as "listingLikes" from "listingLikes" ll 
    join "userData" ud on ud.id = ll."userId" 
    group by ll."userId", ll."listingId" 
    ) 
    "listingLikes" on "listingLikes"."listingId" = l.id
    
    left join ( 
    select "listingId", 
    array_agg(row_to_json(li.*)) as "lineItems" 
    from "lineItems" li group by li."listingId" 
    ) 
    "lineItems" on "lineItems"."listingId" = l.id
    
    left join ( 
    select "listingId", 
    array_agg(row_to_json(cm.*)) as "listingComments" from "listingComments" cm 
    group by cm."listingId" 
    ) 
    "listingComments" on "listingComments"."listingId" = l.id
    The image attached shows that for every row that should be in
    listingLikes
    , it returns a duplicate. So if a
    listing
    has 5 likes, 5 duplicate rows will be in my view.
    • 1
    • 1
  • Default `USER postgres search_path`
    c

    CanRau

    09/26/2022, 8:47 PM
    I did the following:
    Copy code
    sql
    ALTER USER postgres SET search_path TO "$user", public, auth;
    don't even remember exactly where and what for, just that it was based on a comment suggestion to "fix" something. Now I'd like to reset it to default but I'm not sure what the default is supposed to be. I'm totally new to Postgres, have some experience with other SQL DBs ๐Ÿค“ Found this
    Copy code
    sql
    ALTER ROLE postgres SET search_path TO "\$user",public,extensions;
    in Would that do? Or, if the value is actually correct better to do
    Copy code
    sql
    ALTER USER postgres SET search_path TO "\$user",public,extensions;
    Reading , my last example might be the right one tho still not completely sure ๐Ÿ˜ฌ
    g
    • 2
    • 3
  • even returning false I can display data
    s

    sofaking

    09/26/2022, 9:56 PM
    I have a view which is combination of 3 tables, I call this view with anonymous token. I added one of the tables a RLS policy that simply returns
    FALSE
    . I was expecting request I made from a page should fail but to my suprize it didn't . What am I missing here?
    m
    • 2
    • 25
  • Nested ordering not working in V2
    j

    jdgamble555

    09/26/2022, 10:24 PM
    So it seems like I should be able to order by nested values on the supabase js sdk according to this: https://github.com/supabase/supabase/discussions/229
    Copy code
    typescript
    q = this.sb.supabase.from('tags')
      .select('*, pid!inner(*, author!inner(*))', { count: 'exact' })
      .eq('name', tag)
      .order('pid.created_at', { ascending: true })
      .range(from, to)
    tags - pid (fk to posts.id) - ... posts - created_at - ... I'm trying to sort by the posts created at field. I get a 400 error. However, when I comment out the
    .order()
    line, everything works fine. J
    g
    • 2
    • 3
  • How do I get trigger function to show on self hosting?
    r

    rgfx

    09/26/2022, 10:27 PM
    This sections seem to missing, let know what am doing wrong.
    s
    • 2
    • 2
  • converting from blob to URL failed on getServerSideProps?
    n

    NotThatBot

    09/26/2022, 10:28 PM
    when converting a downloaded blob from storage to a URL, i get the error
    TypeError [ERR_INVALID_ARG_TYPE]: The "obj" argument must be an instance of Blob. Received an instance of Blob
    • 1
    • 2
  • SQL queries in Supabase
    h

    harsh singh

    09/26/2022, 10:56 PM
    Hello, I wanted to know how I could run the following SQL query if I'm using the Supabase JavaScript SDK:
    Copy code
    sql
    SELECT * FROM project WHERE email = 'example@email.com';
    j
    • 2
    • 1
  • Friends relationship query
    p

    praisethemoon

    09/27/2022, 12:48 AM
    Hi! I have a table called
    FriendsList
    and i am trying to build a query to fetch the friends of a specific user,
    FriendsList(sender, recipient)
    so it is a bit tricky since the current user can be either a sender or a receiver and its giving me a headache since i am not familiar with supabase queries. Any tips would be greatly appreciated ๐Ÿ™
    s
    • 2
    • 4
  • Environment variables in postgresql function
    u

    uneatenauthor

    09/27/2022, 1:21 AM
    Is there a way to reference environment variables from a postgresql function for use in an http request? I have dev, staging, and prod environments and I don't want to hardcode the urls into the function. Do postgresql functions have access to supabase secrets? Particularly the host url of the supabase project and the api keys? I'd like to use this to call and edge function from the db when a record is inserted.
    g
    h
    • 3
    • 3
  • How do you upsert() but do nothing if there's a conflict?
    h

    HunterAndersonX

    09/27/2022, 2:03 AM
    I'm not looking to modify the user, but want to create one if one doesn't already exist.
    k
    • 2
    • 18
  • Workflows for staging and production with limitations of local dev environment.
    m

    mikelyndon

    09/27/2022, 2:08 AM
    Hi folks. I've been going back and forth on this and I'm at a loss. I've done my best to setup a local dev environment with the CLI so that I can test and develop locally before pushing to the remote db. But without parity between the local dev environment and the online production environment I keep running into issues. The big one is functions and webhooks. I've tried working within my limitations and using what is available in the local dev env to create triggers and functions to replicate webhooks but the setup is brittle. I've also tried setting up my functions and webhooks through the online/production dashboard and then run
    supabase db remote commit
    on a fresh local environment but the migration doesn't include the supabase_functions schema or any of the associated tables and functions. So what would be a reasonable workflow to separate testing from production? I don't want to make changes to the production db while I'm testing. Would I create two projects online - one for production and another for testing? And if so, how can I push changes between the two? Or, do I use the CLI and create custom functions to mimic the supabase functionality?
  • How can I turn this SQL into Supabase-js query?
    z

    ZetiMente

    09/27/2022, 2:24 AM
    select * from profiles INNER JOIN images ON profiles.id = images.profile_id INNER JOIN follows on profiles.id = follows.following_id where follower_id = 12;
    k
    • 2
    • 7
  • No Route Matched With Those Values
    j

    juniorco

    09/27/2022, 2:30 AM
    Following the docs in setting up my first edge function, and ran into
    {"message":"no Route matched with those values"}
    when trying to hit the endpoint. Can't find any info about it online
    c
    • 2
    • 2
  • Supabase Realtime where to get REALTIME_URL?
    j

    jxyz

    09/27/2022, 3:25 AM
    Hi, where do I get the REALTIME_URL?
    g
    • 2
    • 1
  • Pull profile photo(or avatar) url from oauth providers during sign in with supabase auth-helpers
    u

    ๋งคํŠœ

    09/27/2022, 5:29 AM
    Hello I'm trying to automatically update the user table with the avatar_url of whatever auth service the user logs in with. Does anyone have a working solution or tips on how to do this?
    o
    • 2
    • 13
  • Error building nextjs project with auth-helpers
    p

    Prashant Singh

    09/27/2022, 5:40 AM
    https://github.com/supabase/auth-helpers/issues/261
    s
    • 2
    • 1
  • Call Edge Function Every 20 Seconds
    j

    Jim

    09/27/2022, 7:19 AM
    Hey all, wondering if anyone has any suggestions on how to call a supabase edge function at 'second' intervals? Im currently using the cron extension to trigger intervals but it currently only supports the standard cron minute granularity.
    s
    • 2
    • 7
1...323334...230Latest