https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • RLS for products table. where store has several staff members
    d

    dev Joakim Pedersen

    02/01/2023, 10:15 AM
    I would like to add RLS to my products_table. I have a collection of stores. and if the store had only one member there would not be an issue. then I would add on insert of the new product a field called author something But a store can have several accounts linked to it, which means firstly I need to change the stores table to have something more than admin as a field. this would only tell who is admin. not the other accounts. But also I need to create a JWT token or something similar to create my policies that the store_id, and a valid user_id is present. Ah sorry if the question is somewhat vague. 1. I need to create a way for my store table to have several accounts linked to it. 1 admin, and X staff. 2. I need a way to add RLS to products table that ensures you are a valid member of the store that has this product. How could I implement something like this? I'm a bit lost
    g
    • 2
    • 7
  • Inserting rows from Next.js API handler
    a

    akella

    02/01/2023, 10:32 AM
    Im using Next.js. And i have this insert code for public table without RLS:
    Copy code
    javascript
    let insert_result = await supabase.from('items').insert({'name': 333})
    this code works fine when if run it in my client-side components. But when i do it in Next.js api handler, i get this response for insert:
    Copy code
    javascript
    insert_result : {
        "error": {
          "code": "PGRST102",
          "details": null,
          "hint": null,
          "message": "Content-Type not acceptable: application/json, text/plain"
        },
        "data": null,
        "count": null,
        "status": 400,
        "statusText": "Bad Request"
      }
    Select request to supabase works just fine in handler, only insert one breaks, and i cant quite understand what this error says to me. here is full code of my api/insertItem.js
    Copy code
    javascript
    import {supabase} from './supabase'
    
    const handler = async (req, res) => {
        let insert_result = await supabase.from('items').insert({'name': 'whatever',})
    
        res.send({message: 'ok ok',insert_result})
    }
    
    export default handler;
    s
    a
    +2
    • 5
    • 33
  • is every date timestamp that you upload to supabase converted to UTC?
    l

    Lukas V

    02/01/2023, 11:16 AM
    Hello, I am reading here - https://supabase.com/docs/guides/database/managing-timezones "Every Supabase database is set to UTC timezone by default." Does that mean that whatever date user uploads using something like this for example:
    Copy code
    const [selectedDate, setSelectedDate] = useState<Dayjs>(dayjs());
    
      const handleDateChange = (event: React.ChangeEvent<HTMLInputElement>) => {
        setSelectedDate(dayjs(event.target.value));
      };
    Would be converted to UTC timezone once inserted into row? So if you create an timestamp for an offer that ends 02 02 2023 8am in your timezone, each user will see a different ending based on their own timezone?
    j
    • 2
    • 31
  • A bug when using a single address for both Slack and Email when signing in.
    h

    hiroshi nishio

    02/01/2023, 2:52 PM
    When there are two ways to sign in: (1) Sign in with Slack and (2) Sign in with Email. - First, create an account with address A in ①Sign in with Slack. - After that, create an account with the same address A as before in (2) Sign in with Email. - Then, the screen displays "Check your email for the confirmation link. However, no email is actually received. The display content is misleading to users, so please change the display content to something like "The email address is already in use". Is there any way for us to handle this?
    g
    u
    • 3
    • 8
  • Swift Auth Example/Support
    k

    kevlust

    02/01/2023, 4:36 PM
    Hi Supabase team! I recently started building a social networking app and I heard Supabase is the way to go for a database and auth. But I'm using SwiftUI and I'm having trouble finding any examples or tutorials on how to implement Supabase auth in Swift. Do you have any resources or tips for me? Also, any idea when Supabase will have an official Swift package or a Swift auth tutorial? I'm eager to get started! Thanks in advance!
    b
    g
    v
    • 4
    • 4
  • how can I sort a column with the Rest API Url?
    s

    Simon Jimenez Tamayo

    02/01/2023, 4:52 PM
    how can I sort a column with the Rest API Url? I don't know and I don't see any information about it
    g
    • 2
    • 3
  • Get a count for relations without returning relation rows
    a

    Atrox

    02/01/2023, 5:18 PM
    Say I have a query like:
    Copy code
    tsx
    await supabase.from('posts').select('*, comments (*)');
    Is there a way to get a count of the comments, rather than every single comment row, while still returning fields from
    posts
    ?
    g
    s
    • 3
    • 5
  • Best way to increment or decrement an integer column of a record?
    s

    Smardrengr

    02/01/2023, 5:33 PM
    In plain
    sql
    I'd write
    profiles.games_remaining = profiles.games_remaining-1
    but it does not appear you can do this with Supabase API? Or am I wrong?
    g
    t
    • 3
    • 7
  • Syntax for passing UUID into .eq in React?
    c

    cncpowerhour

    02/01/2023, 5:51 PM
    Hey, new to both React and Supabase, so sorry if my terminology isn't correct. I'm trying to pull a column value (p1life) from a particular row with a randomly generated uuid (b12d5cab-8d8b-43d6-b658-10812de0adbe) from my table (testinfo), but I keep getting 406 errors and a PGRST116 error that says "Results contain 0 rows" const { data, error, status } = await supabase .from('testinfo') .select('p1life') .eq('id', 'b12d5cab-8d8b-43d6-b658-10812de0adbe') .single() Is there a particular way I need to pass that uuid? If I don't put it as a string, react doesn't render the page correctly. I don't necessarily have to use randomly generated uuids for my project, I just need to randomly generate the id. If there's a better way to do it, it could just be a number or a mix of numbers and letters.
    g
    • 2
    • 5
  • Delete auth user not working
    s

    STILLWATER;

    02/01/2023, 6:24 PM
    I have following line in my code:
    Copy code
    await supabase_connect.auth.admin.deleteUser(req.user.sub);
    But it is not deleting user im passign the id of auth users table
    g
    • 2
    • 55
  • Next.JS V13 - Supabase Connection
    v

    Vexoa

    02/01/2023, 8:30 PM
    Hello there, I recently used the tutorial/guide you posted here: https://supabase.com/docs/guides/auth/auth-helpers/nextjs-server-components It turns out that the accessToken isn't defined
  • processes empty in PgAdmin
    m

    Mofoga

    02/01/2023, 8:35 PM
    Hei there No matter what I do, the processes list stays empty in the PgAdmin Dashboard. If I for example start a backup, its quite bad not to see if its finished or not. Anyone has experience with this?
  • Left Join via Javascript Client Select
    b

    BoogersLLC

    02/01/2023, 8:50 PM
    Is there a way to do something like this: https://supabase.com/docs/reference/javascript/select#query-foreign-tables But with a
    left join
    ? For context, I want to return from the parent if the foreign table : - Has a specific value - Is missing For example, the query I want to run is exactly:
    Copy code
    sql
    select * from DECKS as decks
    left join spaced_repetition as sr on sr.notebook_id = decks.id
    where decks.user_id = 'MY_ID'
    and (sr.id is null or sr.status = 'INIT')
    Without the
    left
    , I lose all the rows where
    spaced_repetition
    does not exist. i.e. has a
    null
    id
    Hypothetically, I guess I could just call this from a postgres function, but my codebase is already setup to use the
    select
    so just wondering 🙂
    g
    • 2
    • 5
  • How to use Supabase with Riverpod?
    t

    TheSecond

    02/01/2023, 9:03 PM
    Hey guys, does anyone have an idea on how to use Supabase with Riverpod without going nuts? I'm trying to find a convenient and well structured way, but i'm failing...
    l
    • 2
    • 1
  • Getting auth.uid in a postgres function without using SECURITY DEFINER
    d

    drewbie

    02/01/2023, 9:13 PM
    I am trying to create a postgres function that I call via the
    rpc
    method on the JS client. However, when I don't add
    SECURITY DEFINER
    to the function, i get null for
    auth.uid
    . When I add it, its there. However I dont want to add
    SECURITY DEFINER
    since this bypasses RLS policies for the tables being queried/inserted. Any ideas what I may be missing? Here is my function
    Copy code
    CREATE FUNCTION public.create_offer (offer_products jsonb, offer_message text = '')
      RETURNS record
      LANGUAGE plpgsql
      SECURITY DEFINER
      AS $$
    DECLARE
      offer record;
      offer_product jsonb;
    BEGIN
      IF (LENGTH(offer_message) > 0) THEN
        INSERT INTO offers (message, account_id)
          VALUES (offer_message, auth.uid ())
        RETURNING
          * INTO offer;
      ELSE
        INSERT INTO offers (account_id)
          VALUES (auth.uid ())
        RETURNING
          * INTO offer;
      END IF;
      FOR offer_product IN (
        SELECT
          JSONB_ARRAY_ELEMENTS(offer_products))
        LOOP
          IF offer_product ->> 'product_variant_option_id' IS NOT NULL THEN
            INSERT INTO offer_products (product_variant_option_id, price, offer_id)
              VALUES ((offer_product ->> 'product_variant_option_id')::uuid, (offer_product ->> 'price')::numeric, offer.id);
          ELSE
            INSERT INTO offer_products (product_id, price, offer_id)
              VALUES ((offer_product ->> 'product_id')::uuid, (offer_product ->> 'price')::numeric, offer.id);
          END IF;
        END LOOP;
      RETURN offer;
    END;
    $$;
    Any help would be appreciated!
    g
    • 2
    • 2
  • Any information on release of PostgREST 11 to Supabase Cloud
    n

    Nin

    02/01/2023, 9:26 PM
    I'm using the preview PostgREST locally and would like to know what the plan is on being able to use this on Cloud.
    g
    • 2
    • 2
  • Self Deployed Supabase Cannot access LAN smtp
    a

    Anarki

    02/01/2023, 10:32 PM
    How can I connect my supabase running on Docker to my LAN smtp. Docker is completely isolated.
  • Supabase dashboard hanging on updating JWT
    n

    n10000k

    02/01/2023, 11:18 PM
    "Updating JWT secret: started updating"
    g
    • 2
    • 8
  • .in() help for selecting columns in foreign table
    m

    maglev

    02/02/2023, 12:21 AM
    Hi, I'm trying to use the .in() call in the js client as follows but not getting the correct response. Is this possible in the js client or is there a syntax error? Thanks.
    Copy code
    .select( `*, company_data(company_name)`)
                .in('company_data.company_name', ['Target'])
    g
    • 2
    • 28
  • Best way to manage user data they can't modify
    p

    Pythonic

    02/02/2023, 4:10 AM
    Hi there, If I want to store data about a user like whether they are subscribed to the service or whether they are an admin user, but I don't want them to be able to modify (or necessarily read) that data. Then what is the best way to store that data? Should I use the
    public
    schema with read and write disabled? Should I create a new schema called
    private
    or something that only the server can access? Should I modify existing
    auth
    schema? Any tips appreciated. Thanks
    n
    • 2
    • 1
  • select distinct
    e

    elliott

    02/02/2023, 5:57 AM
    Is there no way to select a distinct column using the supabase client library? That is hard to believe but I cannot seem to find it.
  • How do I return an array of values from a foreign table?
    a

    altryne

    02/02/2023, 7:05 AM
    I've tried with count, but it returned 0 (not sure why) I have :
    Copy code
    .from('videos')
        .select(`
        uid, 
        title, 
        description, 
        language, 
        captions(language)
        `)
        ,eq('captions.video_uid', 'uid')
    And it doesn't return anything. How can I add an ARRAY_AGG type column that will return all caption languages (one of the columns) in an array? I can't seem to do this:
    Copy code
    select v.uid, array_agg(c.language)
    from videos v
    join captions c on v.uid = c.video_uid
    where uid = '12345'
    group by v.uid
    limit 1
    s
    g
    • 3
    • 13
  • How to do One to Many relationships in supabase
    c

    culiao

    02/02/2023, 7:05 AM
    I've watched all of the videos and read the documentation - but still can't wrap my head around it. I'm coming from directus where it was much easier. Anyways, lets say I have a 'providers' table and want to have a 'features' list providers id name features id name ammenties id name My goal is: features id name features: ["id1","id2","id3","id4"] ammenties: ["id1","id2","id3","id4"]
    s
    • 2
    • 9
  • Self-host only database
    l

    Levissie

    02/02/2023, 7:11 AM
    Is it possible to only self-host the PostgreSQL db and keep all other services in the cloud version? I prefer the cloud version but need a more extensive database than 8GB.
    s
    • 2
    • 1
  • How do I query select all rows that match a value inside an array of objects inside a JSONB object?
    t

    Twilkey(Limpious)

    02/02/2023, 9:04 AM
    I have a database set up using Supabase. The name of the database is sites. Along with a few other columns, I have a JSONB column named sitedata. Here is an example of the contents of the sitedata column.
    Copy code
    {
      "status": true,
      "response": {
        "theme": {
          "desc": "Description",
          "name": "A theme name",
          "author": "An author",
          "version": "2.14.2",
          "isparent": "Yes"
        },
        "plugins": [
          {
            "desc": "AMP for WP - Accelerated Mobile Pages for WordPress",
            "name": "Accelerated Mobile Pages",
            "author": "Ahmed Kaludi, Mohammed Kaludi",
            "status": "Inactive",
            "update": "Yes",
            "version": "1.0.77.42",
            "new_version": "1.0.79"
          },
          {
            "desc": "Customize WordPress with powerful, professional and intuitive fields.",
            "name": "Advanced Custom Fields PRO",
            "author": "Delicious Brains",
            "status": "Active",
            "update": "No",
            "version": "5.12.3",
            "new_version": "-"
          },
          {
            "desc": "Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.",
            "name": "Akismet Anti-Spam",
            "author": "Automattic",
            "status": "Inactive",
            "update": "Yes",
            "version": "4.2.2",
            "new_version": "5.0.2"
          }
        ]
      }
    }
    I need to be able to fetch each row that shares the value of the key name inside the sitedata.response.plugins array of objects. I have tried many things suggested by people through my Google searches, but nothing works. The last thing I tried was this, but it returns an empty array.
    Copy code
    let { data, error } = await supabase.from('sites')
                .select('*')
                .contains("sitedata", {"response:jsonb->plugins": [{"name": "Accelerated Mobile Pages"}]});
    g
    • 2
    • 2
  • Realtime
    f

    Fayyaz

    02/02/2023, 9:33 AM
    I need to develop a voting application where multiple people cast votes but others can see the count in Realtime, is it something you can do with subbase Realtime and NextJS #realtime #supabase
    s
    • 2
    • 3
  • app.supabase.com crashes with a client error on /database/tables tab
    u

    _alex

    02/02/2023, 9:45 AM
    The web-app crashes when navigating to:
    https://app.supabase.com/project/<project-id>/database/tables
    The exception is
    Application error: a client-side exception has occurred (see the browser console for more information).
    and takes up the entire screen.
    s
    h
    • 3
    • 14
  • Roles and Policies
    s

    Sreenivas

    02/02/2023, 10:04 AM
    I have created 2 roles and 2 policies like below CREATE ROLE DEPT_ROLE ; CREATE POLICY "Enable read access for all users" ON "public"."TEMPLOYEE_MAS" AS PERMISSIVE FOR ALL TO dept_role CREATE ROLE dept_role_insert ; CREATE POLICY "employee_mas insert role" ON "public"."TEMPLOYEE_MAS" AS PERMISSIVE FOR INSERT TO dept_role_insert MY Question: I have 5 users in auth.users tables I want to give the above roles to a user available in auth.users Can you guide me?
    s
    l
    g
    • 4
    • 5
  • different postgres schema
    l

    logemann

    02/02/2023, 10:13 AM
    Hi, is there any problem when creating a new schema in postgres (besides the public one) when it comes to the JS SDK or other areas of supabase? At the very least i need to change the search path somewhere or something?
    s
    • 2
    • 3
  • Does Supabase have facility for multiple clients as does Firebase?
    d

    drg

    02/02/2023, 12:47 PM
    I want to port my Firebase app to Supabase but have a problem with one key usecase. Firebase allows for more than one instance of a fireabase app to be created (usually named 'Secondary app') so that an authenticated user can create users who 'belong' to himself, e.g. a medical doctor in a practice of several doctors can create his own patients and only this doctor can see these patients. The users/tenants of the app are the doctors. The patients are not seen by any other doctors. I am having great difficulty in enabling in supabase a doctor to create his own patients. Insisting that the doctors use an admin server is not acceptable. Any help to find a solution will be gratefully received. Many thanks
    t
    c
    g
    • 4
    • 6
1...116117118...230Latest