https://supabase.com/ logo
Join DiscordCommunities
Powered by
# help
  • j

    jon.m

    02/20/2022, 6:13 AM
    Thank you very much! I should have known. It's late.
  • p

    phil

    02/20/2022, 6:57 AM
    What would be the best way to add more data in the session? For examples, I have a username in a profiles table, so on login, i want to select that username once so its always in the session and i dont have to make repeated database calls every page load
  • c

    connection01

    02/20/2022, 6:59 AM
    How to implement RLS on materialized view, I have the following SQl I want my materialized view to be only accessible by the org owner or org members.
    Copy code
    sql
    CREATE TABLE orgs(
        id serial PRIMARY KEY,
        owner_id INTEGER NOT NULL REFERENCES auth.users(id) ON DELETE RESTRICT,
        name VARCHAR(256) NOT NULL
    );
    
    CREATE TABLE org_members(
        id serial PRIMARY KEY,
        user_id INTEGER NOT NULL REFERENCES auth.users(id) ON DELETE RESTRICT,
        name VARCHAR(256) NOT NULL
    );
  • c

    connection01

    02/20/2022, 7:00 AM
    Copy code
    sql
    CREATE TABLE accounts(
        id serial PRIMARY KEY,
        org_id INTEGER NOT NULL REFERENCES orgs(id) ON DELETE RESTRICT,
        name VARCHAR(256) NOT NULL
    );
    
    CREATE TABLE entries(
        id serial PRIMARY KEY,
        org_id INTEGER NOT NULL REFERENCES orgs(id) ON DELETE RESTRICT,
        description VARCHAR(1024) NOT NULL,
        amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
        credit INTEGER NOT NULL REFERENCES accounts(id) ON DELETE RESTRICT,
        debit INTEGER NOT NULL REFERENCES accounts(id) ON DELETE RESTRICT
    );
    
    CREATE INDEX ON entries(credit);
    CREATE INDEX ON entries(debit);
    CREATE INDEX ON entries(org_id);
    
    CREATE VIEW account_ledgers(
        account_id,
        entry_id,
        amount
    ) AS
        SELECT
            entries.credit,
            entries.id,
            entries.amount
        FROM
            entries
        UNION ALL
        SELECT
            entries.debit,
            entries.id,
            (0.0 - entries.amount)
        FROM
            entries;
    
    
    CREATE MATERIALIZED VIEW account_balances(
        id, -- INTEGER REFERENCES accounts(id) NOT NULL UNIQUE
        balance -- NUMERIC NOT NULL
    ) AS
        SELECT
            accounts.id,
            COALESCE(sum(account_ledgers.amount), 0.0)
        FROM
            accounts
            LEFT OUTER JOIN account_ledgers
            ON accounts.id = account_ledgers.account_id
        GROUP BY accounts.id;
    
    CREATE UNIQUE INDEX ON account_balances(id);
    
    CREATE FUNCTION update_balances() RETURNS TRIGGER AS $$
    BEGIN
        REFRESH MATERIALIZED VIEW account_balances;
        RETURN NULL;
    END
    $$ LANGUAGE plpgsql;
    
    CREATE TRIGGER trigger_fix_balance_entries
    AFTER INSERT 
    OR UPDATE OF amount, credit, debit 
    OR DELETE OR TRUNCATE
    ON entries
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_balances();
    
    CREATE TRIGGER trigger_fix_balance_accounts
    AFTER INSERT 
    OR UPDATE OF id 
    OR DELETE OR TRUNCATE
    ON accounts
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_balances();
  • v

    Vinz

    02/20/2022, 7:51 AM
    Hello, Is there a way to search/filter using OR (or maybe full-text-search) on many-to-many relation on the client side? I can only see examples on a single table thus far. I have an items table, tags table and items_tags (junction table) as an example. Below is my query on the client side for fetching the data but I want to search/filter by checking the title, content, or tags if it matches the input value the user entered on the search bar.
    Copy code
    js
    let { data, error } = await supabase
      .from("items")
      .select(
        `id, title, content, 
         tags!inner(id, name)`
      )
  • p

    PixelPage ᶠᵒˡᶤᶻᶻᵃ

    02/20/2022, 8:37 AM
    There is no promise…
  • r

    realjesset

    02/20/2022, 11:05 AM
    if someone can follow back and help me on my query from yesterday it would be appreciated ^^ thanks https://discord.com/channels/839993398554656828/843999948717555735/944689002173317180
  • p

    PixelPage ᶠᵒˡᶤᶻᶻᵃ

    02/20/2022, 11:34 AM
    Hello, what's the endpoint for deleting/removing an item from a table?
  • p

    phil

    02/20/2022, 11:38 AM
    https://supabase.com/docs/reference/javascript/delete ?
  • p

    PixelPage ᶠᵒˡᶤᶻᶻᵃ

    02/20/2022, 11:39 AM
    i mean rest api endpoint...
  • u

    user

    02/20/2022, 11:42 AM
    Here is the information I believe you are looking for: https://supabase.com/docs/guides/api
  • p

    PixelPage ᶠᵒˡᶤᶻᶻᵃ

    02/20/2022, 11:43 AM
    Yeah I already saw that. There's no info about the endpoint for removing an item...
  • u

    user

    02/20/2022, 12:12 PM
    If you go to the API page in your dashboard and select * bash* and scroll down it'll give you the CURL data with the endpoints, methods, and etc.
  • l

    logemann

    02/20/2022, 1:51 PM
    is there a reason why lots of data types are missing in the DB web editor of supabase?
  • n

    nsadeh

    02/20/2022, 3:30 PM
    Sorry to repost, but does anyone know how to revoke and reissue a service token?
  • a

    and3rsonsousa

    02/20/2022, 5:43 PM
    Is there a way to make requests to multiple tables like graphQL? query { Users {} Posts {} Something {} }
  • c

    chipilov

    02/20/2022, 6:32 PM
    Printing data from select() in Deno.land
  • p

    phil

    02/20/2022, 7:53 PM
    In public I have a table called "decks". Now I am trying to create another table there called "cards" that references "decks":
    Copy code
    create table cards (
      id uuid default uuid_generate_v4(),
      deck_id uuid references public.decks.id on delete cascade,
      created_at timestamp with time zone default CURRENT_DATE,
      front text not null,
      back text not null,
      primary key (id)
    );
    However when I run this query, supabase tells me:
    cross-database references are not implemented: "public.decks.id"
    What does this mean?
    s
    • 2
    • 5
  • p

    phil

    02/20/2022, 7:54 PM
    Did you spell it wrong?
    permissiiontomaketeam
  • p

    phil

    02/20/2022, 8:01 PM
    Proof decks is in public:
  • s

    silentworks

    02/20/2022, 8:15 PM
    Reference to another table
  • a

    Ash

    02/20/2022, 10:03 PM
    How can I get userId via email in the server?
  • d

    dercobrakaiser

    02/20/2022, 10:44 PM
    hi guys i have a quick question how do you handle user roles for your apps
  • d

    dercobrakaiser

    02/20/2022, 10:44 PM
    should i do this in a separate user table?
  • a

    and3rsonsousa

    02/21/2022, 1:39 AM
    if you login() you will receive this data
  • u

    user

    02/21/2022, 2:43 AM
    Can someone tell me how I can upload an image with along with a regular POST request
  • b

    blueslimee

    02/21/2022, 4:38 AM
    hey, is the supabase support email ok? my ticket got closed because i didn't reply, but i did, it went through (at least through protonmail's servers) i also sent an email saying that i did indeed respond with my reply but i got no response
    s
    c
    • 3
    • 5
  • w

    warlic

    02/21/2022, 5:57 AM
    Hi I am trying to self host supabase i installed on my mac with docker desktop but the API section seems to be not working
    g
    • 2
    • 14
  • l

    Lazar Nikolov

    02/21/2022, 6:12 AM
    Hey folks! I'm building a demo app using Next.js and Supabase, and I ran into an issue. I'm using Magic Link auth that takes the user to the home page after logging in, but since my home page is SSR I can't seem to obtain the access token. Does my home page need to be client-side, or there's a way to complete the auth on an SSR page as well?
  • g

    gabydd

    02/21/2022, 7:09 AM
    API section not working self hosted
1...225226227...316Latest