https://supabase.com/ logo
Join DiscordCommunities
Powered by
# javascript
  • d

    Deleted User

    10/09/2021, 10:16 AM
    This might be off-topic, but is there a way to use
    @supabase/supabase-js
    just using a PostgreSQL? In other words, is there a way to use
    .from().select().eq()
    syntax with just a PostgreSQL database? Thank you
    s
    • 2
    • 1
  • s

    silentworks

    10/09/2021, 10:58 AM
    Using supabase-js with Postgres directly
  • u

    user

    10/09/2021, 11:17 AM
    Would someone please be able to take a look at my supabase-js PR #281? Any questions please let me know. Thanks in advance!
  • m

    mlloydw

    10/09/2021, 11:57 PM
    can anyone point me to how I would filter on a uuid field?
  • m

    mlloydw

    10/10/2021, 12:07 AM
    found an answer in this thread: https://discord.com/channels/839993398554656828/894828608672104448/894848952795533353
  • b

    BlindWebDev

    10/10/2021, 7:46 AM
    I'm stuck on authentication. I'm using the example for auth/ui that has the social providers. I can't figure out why onauthstatechange isn't firing when I sign in or out. I am using this in a different component, but that shouldn't matter right? When setUserGlobally() runs on page load, everything works fine, but I would expect it to run automatically when I sign out, thus updating the menu and the rest of the application. Can someone help me out? Here's the relevant code, I think.
    Copy code
    const [finalUser, setUser] = Recoil.useRecoilState(atomUser);
      async function setUserGlobally(user) {
        console.dir(user);
        if (!user) {
          console.log("no user");
          setUser(null);
          return;
        }
        const res = await callApi("/api/users", "post", user);
    
        const data = {
          ...user,
          dbID: res.id,
          customerid: res.customerid,
          subscribed: res.subscribed,
        };
    
        //update recoil state here.
        setUser(data);
      }
      React.useEffect(() => {
        setUserGlobally(supabase.auth.user());
      }, []);
    
      supabase.auth.onAuthStateChange((event, session) => {
        console.log(`on auth state change`);
        setUserGlobally(session.user);
      });
  • b

    BlindWebDev

    10/10/2021, 9:08 AM
    I moved everything inside of a useeffect hook and still no go. Supabase seems to be working for everything else so I know I am passing the url and key properly.
  • b

    BlindWebDev

    10/10/2021, 10:41 AM
    Solved my problem, turns out I had two supabase clients declared and apparently that is a no-no. 🙂
  • s

    SETY

    10/10/2021, 2:23 PM
    Ok I may just be trying to hard to do this. I am using openapi-typescript. It creates types which I import. It doesnt by default mark PKs or FKs as optional (which is fair). All of my keys are UUID. When I am trying to use the type to insert a new row I run into issues. 1. If I leave the FK/PK blank so supabase uses the default on insert, typescript implodes because its required for the type. 2. If I just put a "", null or undefined for those attributes, supabase doesnt like that. When inserting, what can I put for an attribute, that forces it to use the default value? Null, empty string and undefined do not work. I can get around this by just editing the auto generated openapi types and making all PKs and FKs optional, but there must be a way to not do that
  • u

    0xhjohnson

    10/10/2021, 11:44 PM
    @silentworks you ever find a workaround for the hash that gets included at the end of urls in auth methods?
  • j

    jason-lynx

    10/11/2021, 2:32 AM
    a stab in the dark by using SQL syntax: try setting the field to 'default'?
  • s

    SETY

    10/11/2021, 2:34 AM
    I am trying to use the javascript api, inserting a JSON Object
  • s

    SETY

    10/11/2021, 2:34 AM
    that is a row
  • j

    jason-lynx

    10/11/2021, 2:35 AM
    yeah, try setting the value of the object key to 'default'
  • j

    jason-lynx

    10/11/2021, 2:35 AM
    instead of empty string, null, or undefined, just a string that writes 'default'
  • j

    jason-lynx

    10/11/2021, 2:37 AM
    just a guess because in SQL, the equivalent would be
    INSERT INTO tbl(col_with_default) VALUES(DEFAULT)
  • j

    jason-lynx

    10/11/2021, 2:49 AM
    ok was curious and also tried it on my end but didnt work
  • s

    SETY

    10/11/2021, 3:44 AM
    yeah it has to be a value of some sort to be proper json
  • s

    SETY

    10/11/2021, 3:44 AM
    when its removed, it works as intended
  • s

    SETY

    10/11/2021, 3:44 AM
    but then my type implodes
  • j

    jason-lynx

    10/11/2021, 4:45 AM
    i guess then the next easiest thing would be to set your type to be sth like
    Partial<YOUR_DB_TYPE>
    , or
    Omit<YOUR_DB_TYPE, PK>
  • s

    SETY

    10/11/2021, 11:15 AM
    Thanks for the input, yeah I am confused because the from is also the return type and its going to return it with the type. Its already a partial when you push it
  • m

    manubaun

    10/11/2021, 8:18 PM
    Hey guys, first of all awesome work with supabase! I'm trying to make realtime/subscription work with the js client. I try to subscribe to the table 'Author'. It does not work.
    Copy code
    ts
    const client = new SupabaseClient(url, key)
    
    client.form('Author').on('*', (payload)=>console.log(payload)
    But when I use the
    @supabase/realtime-js
    and subscribe directly via the RealtimeClient like this, it works:
    Copy code
    ts
    const socket = new RealtimeClient(supabaseURLRealtime);
    socket.connect();
    const DatabaseListener = socket.channel('realtime:*');
    
    DatabaseListener.subscribe()
        .receive('ok', () => console.log('DatabaseListener connected '))
        .receive('error', () => console.log('Failed'))
        .receive('timeout', () => console.log('Waiting...'));
    
    DatabaseListener.on('*', (change: ChangeResponse<Author>) => {
        console.log('Change received on DatabaseListener', change.record);
    });
    I was debugging it a bit and found out, that the supabaseClient connects to the
    host:8000/realtime/v1/websocket
    endpoint, while with the realtimeClient I connected to
    host:4000/socket
    . No I am not sure, if that is actually the same endpoint. But the
    host:8000/realtime/v1/websocket
    just does not work. Any Ideas? --- edit --- 1. Btw. the websocket connection is working. 2. I also see the Subscription, when calling
    getSubscriptions()
    , but it has state: closed
  • m

    manubaun

    10/11/2021, 8:29 PM
    it also creates alot of subscriptions
  • m

    manubaun

    10/11/2021, 8:34 PM
    I am sorry 🙈 , I had to use
    .subscribe()
    now its working
  • j

    jon

    10/11/2021, 11:31 PM
    hey all
  • j

    jon

    10/11/2021, 11:32 PM
    i'm having issues filtering queries by foreign table attributes:
    Copy code
    const baseQuery = supabase
          .from('jobs')
          .select(
            `
                    id,
                    date_posted,
                    organization_id (
                      name,
                      domain,
                      description_short,
                      headcount
                    ),
                    permalink,
                    title,
                    description
                  `,
          )
          .gt('date_posted', getLastWeek().toUTCString())
          .filter('organizations.name', 'neq', 'Mixpanel');
    Results always include "Mixpanel". What am I missing here?
  • s

    SETY

    10/12/2021, 12:41 AM
    take out the _id from organization_id, should know which key is FK right?
  • j

    jon

    10/12/2021, 1:22 AM
    removing `_id`:
    Could not find a relationship between jobs and organization in the schema cache
  • j

    jon

    10/12/2021, 1:22 AM
    can do
    organizations
    in the select but still same result
1...252627...81Latest