https://supabase.com/ logo
Join Discord
Powered by
# sql
  • g

    garyaustin

    05/07/2022, 3:25 PM
    IS it possible for someone to meet with
  • g

    garyaustin

    05/07/2022, 8:01 PM
    does view update when column type changes
  • j

    jon.m

    05/07/2022, 10:09 PM
    I'm working on coming up with a data model for Facebook Style notifications. I'm really struggling to conceptualize why a naive approach isn't sufficient. By this I mean having a single notification table with columns for the associated entities (user who receives notification, user who created event that caused notification, object that notification is associated with). I've found this article, which breaks things up into three tables, but it seems unnecessary. https://tannguyenit95.medium.com/designing-a-notification-system-1da83ca971bc Does anybody have experience with this type of data model?
  • j

    jon.m

    05/07/2022, 11:10 PM
    So I don’t think there is any benefit besides having a DRY data base
  • j

    jon.m

    05/07/2022, 11:11 PM
    But that won’t really matter early on
  • a

    ash

    05/07/2022, 11:11 PM
    No rows returned from select * from storage.objects
    g
    • 2
    • 3
  • s

    STILLWATER;

    05/09/2022, 9:32 AM
    Hey so i have this query:
    Copy code
    sql
     const { data, error } = await supabase_connect
          .from('Users')
          .select('id,image_url,name,username,age')
          // .eq('country', country)
          .eq('gender', gender)
          .gte('age', age_ll)
          .lte('age', age_ul)
          // .offset(skip)
          .limit(limit);
    and i cant use offset (wrong syntax prolly) and i cant find it on website, any help
    t
    • 2
    • 3
  • s

    STILLWATER;

    05/09/2022, 9:33 AM
    also i want a conditional here that if any of my parameters like country or gender is not given then i want to skip that check
  • s

    STILLWATER;

    05/09/2022, 9:33 AM
    how can i achieve that
  • t

    tourdownunder

    05/09/2022, 10:59 AM
    using logical operators to filter
  • l

    Ludvig

    05/09/2022, 12:16 PM
    Using postgres and plpgsql, I'm trying to create a function with takes in a parameter which is an array of objects.
    Copy code
    sql
    CREATE FUNCTION test_function(products_object_array_input some_data_type) -- what should the data type be? array? jsonb[]?
    An array of objects that I would pass into the function could look like this:
    Copy code
    json
    [
      { "productID": 3, "quantity": 5 },
      { "productID": 1, "quantity": 2 }
    ]
    First question: What should I set the products_object_array_input data type as? array? jsonb[]? Second question: I then want to loop over the array to insert the values of the object array. Again, using plpgsql. How?
    Copy code
    sql
    -- I want to loop over cart_array_input and do this for every object in the array. Sorry for pseudo-code. i = iterator
    insert into order_item(product_id, quantity)
    values(products_object_array_input[i].productID, products_object_array_input[i].quantity);
    s
    • 2
    • 7
  • s

    Scott P

    05/09/2022, 7:56 PM
    Using postgres and plpgsql I m trying to
  • e

    edgaras

    05/09/2022, 9:04 PM
    Beginner question, how do I when creating a table create a reference 1-to-Many? e.g. one person can have many items.
    j
    • 2
    • 9
  • e

    edgaras

    05/09/2022, 9:04 PM
    is it
    items references items
    ?
  • e

    edgaras

    05/09/2022, 9:10 PM
    Or actually maybe I need N-to-M relationship. Because same location can be had by multiple people.
  • j

    jaitaiwan

    05/09/2022, 11:01 PM
    How to do 1-to-n or n-to-n relationships
  • l

    leviwhalen

    05/12/2022, 11:11 AM
    Data modeling question: My application allows users to create webpages. I have a
    pages
    table but I'm not sure if I should create a
    components
    table with rows that have foreign keys from the
    pages
    table -- or use a
    components
    field set as an array type. I am concerned about the large number of rows modified as a user creates and modifies a page, and the high cardinality of this relationship.
    b
    • 2
    • 3
  • b

    burggraf

    05/12/2022, 1:04 PM
    Data modeling question My application
  • s

    STILLWATER;

    05/13/2022, 11:00 AM
    Is there a way i can make a dynamic api which selects the data requested for the model instead of making get for each field??
    g
    • 2
    • 7
  • l

    Lars

    05/14/2022, 12:59 PM
    Hi, I am trying to make and use a function that updates a jsonb field. However, I am having trouble using the variables inside the jsonb object.
    Copy code
    sql
    CREATE OR REPLACE FUNCTION public.updateoffset(site text, offsetnumber integer, toscrape integer)
     RETURNS void
     LANGUAGE sql
    AS $function$
    
    
     update settings set "offset" = coalesce("offset", '{}') || '{"$2": {"toscrape":$3}}'
      where site = $1;
    $function$
    calling it via:
    Copy code
    sql
    SELECT * FROM public.updateoffset('test', 2, 2)
    b
    • 2
    • 16
  • b

    burggraf

    05/14/2022, 2:01 PM
    updating jsonb field in a function
  • c

    celeronCoder

    05/14/2022, 2:24 PM
    Hi, I was starting with the supabase storage and I think there is some bug in the dashboard's SQL editor or I don't know what it is 😅 I ran this command in the SQL editor
    Copy code
    sql
    select storage.foldername('invoices/Test-Patient/2322_22-05-2021.pdf') from storage.objects;
    I expect one result with folders as
    ["invoices", "Test-Patient"]
    but I am getting two duplicate entries. I only have one file in the whole bucket and when I added one more I got three duplicate entries.
    g
    n
    • 3
    • 9
  • k

    kingwill101

    05/14/2022, 8:52 PM
    Hi, how can I automatically set a user_id on inserts? Found this but as i'm new i can't figure out what it's saying. thanks in advance I'm working in dart flutter but i don't want to have the user submitting their own Id
  • g

    garyaustin

    05/14/2022, 9:01 PM
    Just set the default on the column to auth.uid(). Then on insert it will get set based on the jwt uuid. If you want to protect it from being changed by a user you can set a before trigger that always sets new.user_id to auth.uid().
  • m

    mrboutte

    05/15/2022, 5:07 PM
    I'm trying to create a Policy on my
    payment_method
    table with the following SQL
    Copy code
    sql
    SELECT 
      EXISTS(
        SELECT 
          * 
        FROM 
          payment_method 
          INNER JOIN account ON account.id = payment_method.account 
        WHERE 
          account.account_owner = auth.uid()
      );
    ☝️ this works fine in the sequel editor, but when I try to create a policy with it — I get back
    Error adding policy: syntax error at or near "SELECT"
    b
    • 2
    • 8
  • a

    Azura

    05/16/2022, 6:51 AM
    Not sure why it is showing the error
    • 1
    • 1
  • s

    sylar815

    05/16/2022, 5:14 PM
    Hi, here is my list of columns, i am trying to write a query where in the output will be sum of all the "valuesin" for a particular Branch code say "RS032" in a given date range - e.g from 1st march - 3rd march can anyone guide me here with regards to sql query?
    b
    • 2
    • 5
  • b

    burggraf

    05/16/2022, 5:32 PM
    sum query
  • j

    jaitaiwan

    05/17/2022, 1:46 AM
    I have an application that I'm building with supabase that means that there is a many users to many orgs relationship. There's a couple of things I'm trying to work out on a performance basis: 1. Should the user's org association be an array field on the user table or should it be in a joining table of orgs to users? (I think I saw something about it not being recommended to modify supabase tables) 2. It seems like the second option would be a big perf hit if it was used in a security definer function, am I being too cautious with this?
    g
    • 2
    • 6
  • g

    garyaustin

    05/17/2022, 4:00 AM
    user association use in RLS
1...414243...52Latest