https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • I need to use full text search feature through the REST API
    i

    Irfan Ahmed

    01/11/2023, 7:19 PM
    Hello guys, I wanted to use the full text search feature through the REST API call, is it really possible to create an api and use the feature? if yes what is the best method? Any help is appreciated. Thanks!
    v
    g
    • 3
    • 6
  • Supabase-js How to escape string arguments passed to an RPC function?
    m

    miky2fois

    01/11/2023, 8:47 PM
    via SQL I can backslash my string and prefix with E keyword like that
    select * from get_captions_by_word(E'I don\'t') limit 10;
    However, I don't know how to do it with supabase.rpc Any solution?
    o
    • 2
    • 1
  • why is delete not working?
    e

    Esore

    01/11/2023, 9:15 PM
    This is my function to delete a product within a row
    Copy code
    const deleteProduct = async (id: string) => {
        try {
            const { data, error } = await supabaseClient
                .from("product")
                .delete()
                .eq("id", id)
                .select()
                console.log(`delete + ${id}`)
            if (error) throw error
            getProducts()
            
        } catch (error: any) {
            alert(error.message);
        }
    }
    any help would be great!
    g
    • 2
    • 31
  • How do I create a constraint where a column can only be certain values?
    v

    Vik

    01/11/2023, 9:21 PM
    I have a column in my public.friend_requests table that has a status column. I want that column to be limited to the values of "pending", "accepted", "declined", and "blocked". Would it be something like:
    Copy code
    ALTER TABLE friend_requests
    ADD CONSTRAINT status_constraint
    CHECK (status = "pending" OR status = "accepted" OR status = "declined" OR status = "blocked");
    g
    u
    • 3
    • 7
  • How can I make the CLI generate functions using JS instead of TS?
    d

    Dbugger

    01/11/2023, 9:54 PM
    I am sure there is a flag in the CLI that I can use to generate JavaScript, but I have no idea which one it is...
    u
    g
    • 3
    • 4
  • Problem opening the Supabase website.
    a

    Amara

    01/11/2023, 11:07 PM
    Heyy everybody, I am new to supabase but for some reason, I can’t open the website. I have tried in an incognito browser, a different browser and even cleaned out my data, but I still can’t open the website. It says the site can’t be reached https://supabase.com/
    g
    l
    • 3
    • 16
  • Remove all access to tables and functions to anon users
    d

    DYELbrah

    01/11/2023, 11:21 PM
    Hello team, I'm curious if this is the best way to remove all access to the database from anon users? Got these from the following two github pages: https://github.com/supabase/supabase/discussions/1493#discussioncomment-724842 https://github.com/supabase/supabase/discussions/4547
    Copy code
    REVOKE ALL PRIVILEGES ON DATABASE "postgres" FROM "anon";
    REVOKE ALL PRIVILEGES ON SCHEMA "public" FROM "anon";
    REVOKE ALL PRIVILEGES ON SCHEMA "storage" FROM "anon";
    REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA "public" FROM "anon";
    REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA "storage" FROM "anon";
    REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA "public" FROM "anon";
    REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA "storage" FROM "anon";
    REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA "public" FROM "anon";
    REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA "storage" FROM "anon";
    also
    Copy code
    alter default privileges in schema public revoke all on tables from anon;
    alter default privileges in schema public revoke all on functions from anon;
    alter default privileges in schema public revoke all on sequences from anon;
    
    -- the above will only work for future database objects, to revoke current privileges 
    revoke select on all tables in schema public from anon;
    revoke usage on all sequences in schema public from anon;
    revoke execute on all functions in schema public from anon;
    After running these in my local db instance, I do get insufficient privileges messages when attempting to view any table data. I do have RLS in place as well. I want to remove all ANON access since at no point should any data from my app be visible to unauthenticated users. Thank you in advance.
    g
    • 2
    • 2
  • Supabase Auth, NextJS 13 and server components
    l

    logemann

    01/11/2023, 11:30 PM
    Hi, i followed quite closely the (beta) docs at https://supabase.com/docs/guides/auth/auth-helpers/nextjs-server-components and while i like the useful info, i still think there is some more work to do... After implementing the RootLayout as described in the article, i have severe problems getting SSG mode working because of course NextJS tries to statically render some pages at build time and at that point, there is no cookie or headers (next/headers) available but this is a requirement for the supabase-server.ts functionality. Or am i the only one having issues with that approach? SSG is quite an important part of the whole NextJS expierence in my oppinion.
    k
    s
    l
    • 4
    • 5
  • When to use --use-migra for generating migration files
    d

    DYELbrah

    01/11/2023, 11:58 PM
    Hello team, I recently ran a few commands on the SQL editor that effectively removed all access from the anon role. When I create a migration using the following command:
    Copy code
    supabase db diff --use-migra --file revoke_anon_privileges
    The changes are NOT added the migration file, as a matter of fact no changes are detected. When I remove the flag --use-migra, the changes are effectively added to the migration file (using this command):
    Copy code
    supabase db diff --file revoke_anon_privileges
    I'm not sure when my team should be using --use-migra, vs not? Anyone got some insight? Thank you in advance.
    s
    • 2
    • 2
  • Manually build and install extension on a hosted DB
    w

    Will Ernst

    01/12/2023, 1:10 AM
    I would like to use an extension that is not in the supported list: https://github.com/sraoss/pg_ivm. In a perfect world I'd download the src files our DB's machine and build the source from there (then run CREATE EXTENSION...). But I'm not sure how to access our DB server directly. So, is there a way to access our DB server (ie SSH in)? I haven't been able to find a way to do that. And if not, what is the best way to build and install an extension that is not in the supported list? Thank you!
    g
    • 2
    • 8
  • How to wipe remote database? Similar to supabase db reset in local development
    d

    DYELbrah

    01/12/2023, 2:38 AM
    Anyone have any idea how I can wipe a remote db that I am using as a sandbox? I want to remove all the rows, and rerun the migration from my local development. Any ideas would be highly appreciated!
    j
    s
    • 3
    • 2
  • Is `createContext` necessary from react if you are using SessionContextProvider from Supabase?
    c

    Cabtn

    01/12/2023, 4:52 AM
    Title sums it up, If my
    _app
    is wrapped like so:
    Copy code
    const MyApp = ({ Component, pageProps }: AppProps) => {
      // Create a new supabase browser client on every first render.
      const [supabaseClient] = useState(() => createBrowserSupabaseClient());
    
      return (
        <SessionContextProvider
          supabaseClient={supabaseClient}
          initialSession={pageProps.initialSession}
        >
          <Component {...pageProps} />
        </SessionContextProvider>
      );
    };
    do I need to do the step described in this egghead lesson linked below? If so, why? What is the difference between the two context. https://egghead.io/lessons/next-js-make-user-state-globally-accessible-in-next-js-with-react-context-and-providers
    • 1
    • 1
  • useEffect not working on Supabase Auth
    c

    Cabtn

    01/12/2023, 5:26 AM
    Hey there, I have a login function below that uses Supabase Auth but I want to trigger a useEffect when my user object changes from null, that doesn't seem to be happening, is their an onclick or an optimal time to trigger my api call to stripe and make a new customer that can be added to my supabase table? Do I need what I described in this post here: https://discord.com/channels/839993398554656828/1062957325251530832 Code:
    Copy code
    import { useEffect } from 'react';
    
    import { useSupabaseClient, useUser } from '@supabase/auth-helpers-react';
    import { Auth, ThemeSupa } from '@supabase/auth-ui-react';
    import { useRouter } from 'next/router';
    
    import { getURL } from '../utils/helpers';
    import { axiosRequest } from '../utils/utils';
    
    const Login = () => {
      const router = useRouter();
      const user = useUser();
      const supabaseClient = useSupabaseClient();
    
      console.log('User', user);
      useEffect(() => {
        if (user) {
          console.log('We are going to make a request');
          axiosRequest('/api/create-customer', { id: user.id, email: user.email });
          router.replace('/shopping-cart');
        }
      }, [router, user]);
    
      if (!user)
        return (
          <div className="flex justify-center height-screen-helper">
            <div className="flex flex-col justify-between max-w-lg p-3 m-auto w-80 ">
              <div className="flex justify-center pb-12 "></div>
              <div className="flex flex-col space-y-4">
                <Auth
                  supabaseClient={supabaseClient}
                  providers={['google']}
                  redirectTo={getURL()}
                  appearance={{
                    theme: ThemeSupa,
                    variables: {
                      default: {
                        colors: {
                          brand: '#404040',
                          brandAccent: '#52525b',
                        },
                      },
                      ....
    
    export default Login;
  • CDN Custom Domain Support
    c

    c0rrupt

    01/12/2023, 7:00 AM
    Is it possible or a planned feature to apply custom domains to cdn links?
  • Supabase Storage API upload finished before it should be (Github Actions)
    a

    anggoran

    01/12/2023, 7:25 AM
    Hello, so yesterday I tried to upload a .dmg file to the Supabase with Storage REST API. And it finished before the file was successfully uploaded.
    • 1
    • 2
  • How do you count all the rows in the table using supabase python?
    b

    Buradorii

    01/12/2023, 7:28 AM
    I can't find it in the docs and the Javascript way isn't working. Thanks!
    m
    • 2
    • 6
  • Quotes when joining tables
    m

    Markeem

    01/12/2023, 7:50 AM
    Why can't I use singlequotes when joining tables with the js client ? It only works with backticks for me.. Is this documented somewhere ?
    g
    • 2
    • 1
  • 500/404 server error using supabase.js?
    k

    kanintesova

    01/12/2023, 7:58 AM
    Hi, I can fetch data fine by standard SQL query. But when I try the API in a node.js app it does not work. All credentials are fine. The API EDGE NETWORK logs gives a 404: In the request headers:
    Copy code
    "headers": [
        {
          "accept": "*/*",
          "cf_cache_status": null,
          "cf_connecting_ip": "retracted",
          "cf_ipcountry": "SE",
          "cf_ray": "78843d233ce30a2c",
          "content_length": null,
          "content_location": null,
          "content_range": null,
          "content_type": null,
          "date": null,
          "host": "retracted.supabase.co",
          "referer": null,
          "sb_gateway_version": null,
          "user_agent": "undici",
          "x_client_info": "supabase-js/2.4.0",
          "x_forwarded_proto": "https",
          "x_forwarded_user_agent": null,
          "x_kong_proxy_latency": null,
          "x_kong_upstream_latency": null,
          "x_real_ip": "retracted"
        }
      ],
      "host": "retracted.supabase.co",
      "method": "GET",
      "path": "/rest/v1/public.checkout",
      "port": null,
      "protocol": "https:",
      "sb": [],
      "search": "?select=resource",
      "url": "https://retracted.supabase.co/rest/v1/public.checkout?select=resource"
    }
    And here is the relevant app code:
    Copy code
    // Initialize the JS client
    const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY);
    
    app.get('/', async (req, res) => {
        try {
            // make request to Supabase API
            const { data } = await supabase.from('public.checkout').select('resource');
    I don't know what is wrong really, and what I am missing. Any help or pointers would be lovely. Thanks people. ❤️
    g
    • 2
    • 1
  • Can I query "DISTINCT" column values using supabase?
    m

    MoreeZ

    01/12/2023, 8:01 AM
    I am trying to make the following query:
    Copy code
    sql
    SELECT DISTINCT namespace FROM file_system
    In JavaScript I can select all "namespace" columns but I only need the distinct ones.
    Copy code
    js
    supabase.from("file_system").select("namespaces");
    s
    • 2
    • 1
  • Anyway to enable realtime on starting the server?
    i

    itog

    01/12/2023, 8:09 AM
    Do we need to manually enable
    realtime
    for the tables? When I use local server, I always have to enable realtime manually. And after enabling it, `supabase db diff`don't find any changes. So, I have to enable again when I restart the server. Is there anyway to set tables realtime on starging the server?
    s
    • 2
    • 2
  • Is Supabase the new and improved Django rest framework?
    a

    AntDX316

    01/12/2023, 9:11 AM
    I'm trying to do a rest API server and I heard security has to be good. Placing API in source code isn't good and if moved outside into an .env area it can still be reversed engineered. A DigitalOcean cloud engineer said to see FaunaDB and Supabase. Upon research it seems Supabase isn't FaunaDB and Supabase seems to have UI and better to create rest API? Now, I want to use Android Studio Kotlin but looked into Flutter too. Can I easily do real-time commands to each app?
    k
    • 2
    • 8
  • How to make an RPC function that returns an array?
    m

    MoreeZ

    01/12/2023, 11:28 AM
    I have a table "file_sytem" and I want to return all distinct values from a column "namespace". I can do that in sql like this:
    Copy code
    sql
    select distinct namespace from file_system
    But when I try to make an sql function I can only get a single record back. When I try to return either json or jsonb I get this error
    return type mismatch in function declared to return jsonb
    Could someone maybe help me convert this query into a working plpgsql function?
    ł
    • 2
    • 2
  • AuthUnknownError: Unexpected token 'F', "Function not found" is not valid JSON
    d

    Deidara

    01/12/2023, 12:09 PM
    Hey! I've created a simple edge function to create a user by email. Steps: 1. Enable email auth flow in project 2. Create edge function 3. Create supabase client 4. Call auth.signUp with email, password 5. Got errors on the local and prod Help please!
    • 1
    • 1
  • XX000 TypeError: Cannot destructure property `base` of 'undefined' or 'null'.
    r

    rem

    01/12/2023, 1:08 PM
    I'm getting the above error (from the subject) when I try to run a simple line:
    Copy code
    await supa.from("teams").insert(newTeam) // returns with error prop
    All the fields in the
    teams
    table are being included as properties in
    newTeam
    with the exception of
    id
    which I've assumed will auto assign (as it's doing this when some earlier records were inserted). I've also checked the column properties and they all have "allow nullable" on them, but this error seems to be coming from inside of supabase trying to destructure… something. Has anyone else seen this or have any suggestions I might be able to poke around?
    g
    s
    • 3
    • 20
  • Stream upload large files
    m

    Migu

    01/12/2023, 1:13 PM
    I'm trying to understand how to upload large files to Supabase through streaming to avoid timeouts and/or memory exceeding issues (either by using the REST API or the JS client). I've read https://github.com/supabase/storage-api/pull/29 and the blog article from January 2022 (I believe) showing the same snippet but I fail to understand how it would work. In my head, "streaming" means adding some bits at the end of the file until you reach the end of your stream (i.e. close some sort of connection?) but the Storage REST API (https://supabase.github.io/storage-api/#/) seems to indicate that a PUT
    /object/{bucketName}/{wildcard}
    replaces the file with the buffer we send… I have very little knowledge in the domain so it gets a bit confusing reading some stuff but I reckon it may involve at least
    fs
    . Has anyone already tackled the subject? My use-case is a very large XLSX file (200k lines) that I create with libraries like xlsx-populate and I need to stream it otherwise I get timed-out quite quickly. Thanks!
    • 1
    • 3
  • HCaptcha verification with docker
    i

    ItsEthra

    01/12/2023, 1:47 PM
    Hello, I have a docker setup and I want to add hcaptcha verification to my register page, how can I do this? I couldn't find any information about that, there are no captcha related environment variables in example
    .env
    and also page where I am suppose to set my secret key is missing from studio.
  • single or maybesingle on foreign table?
    p

    pepegc

    01/12/2023, 1:54 PM
    We can apply a limit on a foreign table query, but it still comes as a list. Can we somehow apply a single or maybesingle? https://supabase.com/docs/reference/javascript/limit
    g
    • 2
    • 1
  • Connect Auth to external DB
    a

    a guy

    01/12/2023, 2:05 PM
    I'm not using the Supabase DB because it doesn't play well with Prisma, and I'm using Redwood, which implements it. So, how do I go about triggering a call to my other PostgreSQL instance upon a create/update/delete in Auth? Is there a doc page for this? I didn't see one. I know I could make a Prisma call following any Auth calls, but I'd like to know if there's a more direct way that doesn't require lines of code in my project.
    g
    • 2
    • 3
  • How to migrate users [solved]
    b

    Bad Gifter

    01/12/2023, 2:11 PM
    I am trying to migrate from Nhost to Supabase. Very similar data structure for users and all. Was hoping to just bring the user id's from nhost over to supabase by adding the auth.users rows with a script since we have about 20 tables and they all rely on the user_id to stay the same that was created on signup. Issue is, I'm testing adding user's directly to the auth.users table, which works, but then when trying to login with the social provider for that email, it says "Database error saving new user" I looked into the logs and all it shows is that for some reason there auth is trying to insert a new user with ofc, the same email, into the auth.users table. If the email is already in the table, why is the auth not catching that and skipping the auth create user ? I feel I am missing some data insert somewhere.
    • 1
    • 2
  • Adding constrains to fields
    d

    Dbugger

    01/12/2023, 2:32 PM
    How can I add constrains to my VARCHAR fields? I did not find anything in the interface.
    g
    j
    • 3
    • 5
1...959697...230Latest