https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Created a new function under auth and now I can't delete it 😅
    v

    Vik

    12/23/2022, 2:01 AM
    I created a new function under auth on accident and now I can't delete it. I see it when I go to create a new trigger and selecting a function. I tried using the SQL Editor to run:
    DROP FUNCTION IF EXISTS add_onboarding_key();
    But that didn't work either.
    g
    • 2
    • 2
  • AWS SDK setup for storage
    a

    ardyfeb

    12/23/2022, 2:39 AM
    Where i can get credentials storage api such as
    accessKeyId
    secretAccessKey
    endpoint
    ?
    g
    • 2
    • 11
  • Which table should I store this data in?
    h

    Hamburger

    12/23/2022, 2:45 AM
    Would it be better to store usernames and profile pictures of users in the
    public
    schema or the
    auth
    schema?
    g
    • 2
    • 4
  • how to add timestamp to table with epoch time
    u

    ${fence}

    12/23/2022, 3:11 AM
    E.g: 1671764933.04014
    s
    • 2
    • 1
  • Rate Limit for api calls ?
    y

    YokoWasis

    12/23/2022, 3:51 AM
    Is there a rate limit for api calls of CRUD operation per seconds ? Let's say I have an exam app that's used by 1M users simultaneously, and because I want the answers get sent to the server immediately, it means there is approximately 1M api call per 5 seconds or so. Can the managed supabase handle this ?
    s
    a
    g
    • 4
    • 7
  • I am looking at building user group security roles for the first time.
    l

    LearningJourney

    12/23/2022, 4:00 AM
    I am looking at building user group security roles for the first time. Here is my thinking: Create a table of profiles, security groups, permissions. and tables linking these together. I need to protect the database with row level security based on the group that the current logged in user belongs to, right? What would this look like, or is my thinking completely wrong? Or would it be more reasonable to not deal with RLS and handle this in the backend instead of Supabase using the regular logged in API
    g
    • 2
    • 2
  • Master account and subaccounts
    e

    Elfhild

    12/23/2022, 4:02 AM
    Can we create master account and sub accounts on supabase?
    s
    • 2
    • 7
  • error failed to delete user
    h

    Hege

    12/23/2022, 5:18 AM
    What does the error failed to delete user mean? I'm trying to delete a user but it isn't letting me. All the relationships with said user are gone so I'm unsure why it wouldn't let me delete it from auth.users
    s
    g
    • 3
    • 51
  • How to duplicate to new org
    h

    hotbelgo

    12/23/2022, 6:47 AM
    I have a db that I used for a project last year. I want to use the project again this year and created a new org to host the data. I want exact copies of the DBs' structures and it would be useful to have last year's data to start with as I fine tune the front end code (svelte => sveltekit...) How would I go about that?
    g
    • 2
    • 1
  • Can you use a locally hosted realtime DB?
    z

    zilchg00d

    12/23/2022, 7:57 AM
    I'm working with Electron and would like to use a locally hosted database for my application. Will realtime work on the localhost? What is the best way to detect changes to tables and update the UI on the fly?
    g
    • 2
    • 1
  • Conflating organisation and person free projects
    m

    madsbuch

    12/23/2022, 8:26 AM
    I am a part of an organisation that uses 2 free projects. It seems to remove any allowance of free projects on my personal organisation. This is not ideal, as I do have other ideas I want to test out, that are not a part of this organisation. It it possible to have this constraint removed?
    s
    • 2
    • 1
  • Foreign key on table with composite primary key
    v

    vikramark

    12/23/2022, 8:43 AM
    How to create a foreign key to a table with two columns as primary key, which do not have unique constraints by themselves ?
    • 1
    • 1
  • SOLVED - Using the newly created ID to router.push in NextJS
    t

    Taqi

    12/23/2022, 10:00 AM
    Hey all, currently stuck on the issue that I want to open the page for the recently created record in the database. On submit, I insert given information and return it with select. Then if there is data, I log it to the console (this works also) I try to useState() the ID in a value => id2. This does not work, as I don't return the console.log(id2) with the correct information. Anyone knows how to resolve this? I would like to push the web page to the newly created ID, so that I can create line information on my application.
    j
    • 2
    • 4
  • Update via URL
    i

    illUka

    12/23/2022, 11:26 AM
    How can i update column where ID = 1 via URL like i GET data : https://[id].supabase.co/rest/v1/device?select=id&apikey=[mykey] I try this one: https://[id].supabase.co/rest/v1/device?id=eq.1&column_to_update=[newValue]&apikey=[mykey]
    g
    • 2
    • 2
  • React Native how to upload image to storage?
    t

    Talajax

    12/23/2022, 11:33 AM
    Hi, i'm using react native with expo and i'm trying to upload an image to storage but i keep getting a "Network Request Failed" error. I was following the documentation, but first the react-native-document-picker was not working, so i'm using expo image picker. This is my function
    Copy code
    let result = await ImagePicker.launchImageLibraryAsync({
          mediaTypes: ImagePicker.MediaTypeOptions.All,
          allowsEditing: true,
          selectionLimit: 1,
          aspect: [4, 3],
          quality: 1,
        });
    
        if (!result.canceled) {
          // setImage(result.assets[0]);
    
          const file = result.assets[0];
          const response = await fetch(file.uri);
          const blob = await response.blob();
    
          try {
            const photo = {
              uri: file.uri,
              type: file.type,
            };
    
            const fileExt = photo.uri.split(".").pop();
            const filePath = `${Math.random()}.${fileExt}`;
    
            const imageFile = new File([blob], `${Math.random()}`);
    
            let { error } = await supabase.storage
              .from("avatars")
              .upload(filePath, imageFile);
    
            if (error) {
              throw error;
            }
          } catch (error: any) {
            Alert.alert(error.message);
            throw new Error();
          }
        }
    g
    • 2
    • 1
  • RLS to show premium_content to profile.is_subscribed
    c

    CesarNML

    12/23/2022, 11:39 AM
    I'm following allowing with this tutorial: https://egghead.io/lessons/supabase-implement-gated-content-using-row-level-security-with-supabase However, when I tried to implement the RLS policy on the
    premium_content
    table to only allow access to
    profile.is_subscribed = true
    it seems that my policy is always evaluating to
    false
    . Below is the RLS policy on
    premium_content
    table:
    Copy code
    sql
    (EXISTS ( SELECT profile.id,
        profile.created_at,
        profile.is_subscribed,
        profile."interval",
        profile.stripe_customer,
        profile.email
       FROM profile
      WHERE ((uid() = profile.id) AND (profile.is_subscribed = true))))
    Below is the current database schema:
    Copy code
    ts
    export interface Database {
      public: {
        Tables: {
          lesson: {
            Row: {
              created_at: string | null
              description: string | null
              id: number
              title: string | null
            }
          }
          premium_content: {
            Row: {
              created_at: string | null
              id: number
              video_url: string | null
            }
    
          }
          profile: {
            Row: {
              created_at: string | null
              email: string | null
              id: string
              interval: string | null
              is_subscribed: boolean | null
              stripe_customer: string | null
            }
          }
        }
    }
    I have verified that if I turn off RLS on the
    premium_content
    table the data I want is sent down by supabase. Thank you in advance for any help.
    • 1
    • 1
  • Many to many table issue
    m

    Mozes

    12/23/2022, 1:30 PM
    Hello, I have "posts" table & "profiles" table & "post_publisher" join table all is working as expected but I have problem in timeline page (which is realtime listen to posts table for all actions) when the user adds a new post, it returns in the real-time post, but without the profiles property how to get profiles property in new posts in realtime?
    g
    • 2
    • 4
  • How to filter in query by jsonb
    u

    upwell

    12/23/2022, 2:35 PM
    Hello, I want to search entries by some property in jsonb. You can see the json structure on the picture. I tried following code added to query to find which entry json contains searched text but so far without success.
    .contains('body:jsonb->>content->>content', ['content->>text: ' + search.value])
    g
    • 2
    • 1
  • Cant update row in table with python requests module
    l

    lake_mattiato

    12/23/2022, 3:00 PM
    So i have a function written in python:
    Copy code
    python
    def set_message_read_status_to_true(message_id):
    
        headers = {
            'apikey': 'api_key',
            'Authorization': f'Bearer apikey'
        }
    
        data = '{ "is_read": "true" }'
    
        response = requests.patch(
            headers=headers,
            params=data,
            url=f'https://URL.supabase.co/rest/v1/messages?id=eq.{message_id}'
        )
    
        print(f'https://URL.supabase.co/rest/v1/messages?id=eq.{message_id}')
    
        return response.json()
    but i get the following response
    Copy code
    {'code': 'PGRST102', 'details': None, 'hint': None, 'message': 'Error in $: not enough input'}
    Any idea how to solve this?
    s
    g
    • 3
    • 12
  • Question about the 'Email Prefetching' limitation section
    f

    Florian

    12/23/2022, 3:22 PM
    The docs have this entry (see screenshot). But isn't the problem much worse than just "broken links"? The way I see it, this will verify emails wrongly. Even if the user doesn't actually own this address.
    g
    • 2
    • 17
  • How do you make sure users are logged in after they click their Sign Up verification email (React)
    e

    eben

    12/23/2022, 4:46 PM
    Right now my users sign up using the
    Copy code
    js
    await supabase.auth.signUp
    function. It sends a mail to the used email that has a link. When users press the link they are just brought back to the "/" route and are forced to Log In using a form to gain access to their account.
    g
    • 2
    • 22
  • Role level access using RLS
    r

    redwookie

    12/23/2022, 5:55 PM
    Can anyone help me creating a policy which allows someone with an admin value in a profiles table to update other entries in the table, when there is a general policy which allows for users to only update they own data? is it even possible?
    g
    z
    • 3
    • 7
  • Cannot read properties of undefined (reading 'createClient') error when using Vite + SvelteKit
    h

    Hypex

    12/23/2022, 6:18 PM
    Hi, I'm trying to use SvelteKit with Supabase Auth, but when I try to create a Supabase client with this code:
    Copy code
    js
    import { createClient } from '@supabase/auth-helpers-sveltekit'
    
    export const supabaseClient = createClient(
        import.meta.env.VITE_PUBLIC_SUPABASE_URL,
        import.meta.env.VITE_PUBLIC_SUPABASE_ANON_KEY,
    )
    And this
    .env.local
    file:
    Copy code
    VITE_PUBLIC_SUPABASE_URL=https://publicurl.supabase.co
    
    VITE_PUBLIC_SUPABASE_ANON_KEY=anonkey
    I get this error:
    Copy code
    TypeError: Cannot read properties of undefined (reading 'createClient')
        at /home/skyfall/Projects/thing/src/lib/db.ts:3:30
        at async instantiateModule (file:///home/skyfall/Projects/thing/node_modules/vite/dist/node/chunks/dep-0bae2027.js:52198:9)
    How do I get my code to successfully create a client?
    g
    c
    • 3
    • 9
  • Insert using Self Hosted Supabase and NestJS not working
    r

    Rayk0

    12/23/2022, 6:57 PM
    Hello, First of all, sorry for my English. Me and a friend recently tried to switch from Supabase cloud based to a self hosted solution. I followed the main documentation and another tutorial in order to complete the setup with Docker. I also used Cloudflare to setup an https domain and Caddy for a reverse proxy. I can now access my Self hosted Supabase online using my domain name but i have quite a few things not working. First : When i try to invite a user in the Authentication part, i have this error message "Failed to invite user: name resolution failed" Second (which is actually the biggest problem): I can create tables, edit them and make SQL Requests. I can also insert rows directly from the studio. BUT when using NestJS and postman to make insert request, it does not work without any error message. Indeed, GET and DELETE requests are working fine, but when we try to use the insert method from the NestJS supabase client, it does its things without sending any error and inserting anything. We tried using the anon key as the supabase key, and also the service role key, but both did not work for insert. When the key is wrong, we do get the invalid credentials error. We used the exact same code between the cloud based solution and the self hosted one, but we really have no idea why this does not work, and it is kinda frustrating. If anyone could help us ! Regards. PS: The most weird thing is really the fact that we can insert rows via Supabase self hosted but not via NestJS
    s
    • 2
    • 3
  • Using html2canvas to generate thumbnail and store either in supabase column OR is storage
    d

    DDupasquier

    12/23/2022, 7:28 PM
    I'm trying to figure out how to generate a thumbnail from an existing dom element and either send it to the db as a webp OR as base64. But I can't get either of them to work xD If I go the base64 route (the least ideal route) I could store the string as a column in my table. If I go the webp route (more ideal) then I'll be saving it to a bucket. Here is the code I have so far: The function which generates the file:
    Copy code
    js
    export const screenshotCanvas = (element: string) => {
        const el: HTMLElement | null = document.querySelector(element);
        if (el) {
            html2canvas(el).then((canvas) => {
                canvas.toBlob((blob) => {
                    const file = new File([blob], 'thumbnail.webp', {
                        type: 'image/webp'
                    });
                    console.log(file)
                    return file;
                });
            });
        }
    };
    The function which calls the previous function and plugs it into my supabase service:
    Copy code
    js
    const doScreenshot = () => {
            const file: File = screenshotCanvas('.canvas');
            uploadThumbnail(file, info.id);
        };
    The supabase service:
    Copy code
    js
    export const uploadThumbnail = async (
        file: string,
        id: number
    ) => {
        const { error } = await supabase.storage
            .from('page-screenshots')
            .upload(`thumbnail-${id}.webp`, file, {
                upsert: true,
                contentType: 'image/webp'
            });
    
        if (error) {
            throw new Error(error.message);
        }
    };
    When I console.log the file, I get a data structure that looks like this:
    Copy code
    json
    File {name: 'thumbnail.webp', lastModified: 1671822552823, lastModifiedDate: Fri Dec 23 2022 11:09:12 GMT-0800 (Pacific Standard Time), webkitRelativePath: '', size: 23795, …}
    lastModified
    : 
    1671822552823
    lastModifiedDate
    : 
    Fri Dec 23 2022 11:09:12 GMT-0800 (Pacific Standard Time) {}
    name
    : 
    "thumbnail.webp"
    size
    : 
    23795
    type
    : 
    "image/webp"
    webkitRelativePath
    : 
    ""
    [[Prototype]]
    : 
    File
    When I send this data to the db, I get something which resembles a webp, but it's a zero bytes file which contains nothing. I realize that this might not be an actual supabase problem, but maybe someone on here has some insight. I've been messing with this for almost 3 days and I'm losing my mind xD
    n
    • 2
    • 1
  • Subscribe and get last changes
    e

    Elfhild

    12/23/2022, 7:58 PM
    Is there any way to subscribe to table changes (email tables) but also get the latest 20 emails? Like RethinkDB live queries?
    • 1
    • 1
  • What approach should I use?
    c

    Creix

    12/23/2022, 8:50 PM
    Hello! I'm trying to create a ticket scanning app using Supabase. The point where I'm struggling now is how can I sync data between different devices and the supabase database with the possibilities for the devices to also work offline. For example if i have two scanning devices for the same event, what's the best way to sync the data between the two so that the same ticket can't be scanned from the two devices? Should i use realtime mode built in Supabase (Will it scale?) ? or just query and updating periodically the database? I also read that Supabase team is working to support offline mode, as for now is it possible with some workaround to have a similar function in React Native?
  • How to record API Calls
    c

    Crownie

    12/23/2022, 9:11 PM
    I don't know if this is the right place to ask but my manager want's me to this feature but i don't know how, i was thinking if supabase has a way to record api calls.
    g
    • 2
    • 3
  • Requiring additional auth on the Supabase API
    j

    joshtwist

    12/23/2022, 9:51 PM
    I want to use a serverless gateway to add rate-limiting and quota checking to my supabase API. I'm using supabase Auth and RLS so I want the JWT token to flow through the gateway. However, I want to be sure that ONLY the gateway can call the API directly. Is there a way to require additional security on the supabase API? Like a shared-secret passed as an
    api-key
    header in addition to the
    authorization
    header.
    g
    • 2
    • 26
  • Filtering Related Records
    t

    typeleven

    12/23/2022, 10:08 PM
    How do I filter related records? For example how would I perform this query but filter so that the only invoice_lines with a qty of > 0 are returned? supabase.from('customers').select('id,name,invoices(id,total,invoice_lines(id,qty,total,products(id,name,price)))')
    g
    • 2
    • 3
1...777879...230Latest