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

    jaf

    01/10/2022, 3:52 PM
    How do I express this query with the JS SDK?
    SELECT * FROM test_products_2 WHERE main_sku = sku
  • g

    garyaustin

    01/10/2022, 3:56 PM
    You can't. https://github.com/PostgREST/postgrest/issues/1105 recommendation is a computed column with that condition or view. RPC would also work.
  • j

    jaf

    01/10/2022, 4:00 PM
    Thanks
  • t

    TremalJack

    01/11/2022, 1:25 PM
    how is possible run a LEFT JOIN query with supabase-js?
  • t

    TremalJack

    01/11/2022, 1:27 PM
    Im using right now this.supabase.from('channel_messages').select('*,channel_files(*)').eq('channel_id', this.data.channelID) but return me data only if the record is in both tables
  • e

    eMeRiKa

    01/11/2022, 1:31 PM
    Is it possible to select data order by random() ?
  • e

    eMeRiKa

    01/11/2022, 1:36 PM
    I found my answer here https://github.com/supabase/supabase/discussions/2299
  • d

    drex

    01/11/2022, 6:33 PM
    any idea why im getting thi
  • d

    drex

    01/11/2022, 6:36 PM
    nvm
  • d

    drex

    01/11/2022, 6:36 PM
    got it
  • j

    jesucrypto

    01/11/2022, 7:37 PM
    does anyone knows how do i insert a new worker inside the worker column?
    s
    m
    • 3
    • 4
  • j

    jesucrypto

    01/11/2022, 7:38 PM
    the table name of project there's an worker list does anyone knows how do i add a new worker inside it?
  • s

    silentworks

    01/11/2022, 7:54 PM
    Inserting into a column
  • s

    stibbs

    01/12/2022, 6:44 AM
    I don't think left joins can be done via just JS (yet). You could move your query to a view and then call the view?
  • j

    jaf

    01/12/2022, 11:56 AM
    When I do a select with the JavaScript library it returns a
    data
    and a
    body
    property with exactly the same values in it. What's the reason for this?
    s
    • 2
    • 4
  • d

    dohman

    01/12/2022, 8:20 PM
    I'm trying to drop a row from the Supabase database. Luckily, I was doing this on my local environment because it dropped my whole table 😅
    Copy code
    js
    rejectEntry: async function(item) {
        let index = this.items.indexOf(item);
        this.items.splice(index, 1);
        const deleteEntry = await supabase
          .from('submissions')
          .delete()
          .match(item.id)
        if (deleteEntry.error) throw deleteEntry.error;
      },
    Can anyone suggest what was wrong? I assumed that .match would match the item ID from the table and remove that.
    s
    m
    • 3
    • 3
  • d

    dohman

    01/12/2022, 8:24 PM
    Nevermind, figured it out;
    Copy code
    js
    const deleteEntry = await supabase
          .from('submissions')
          .delete()
          .eq('id', item.id)
  • s

    silentworks

    01/12/2022, 9:20 PM
    Why did my entire get dropped?
  • h

    Haba

    01/12/2022, 10:09 PM
    Hi. How can I retrieve data using a JSON key? i try:
    const {data, error} = await supabase.from('Cards').select('*').eq('device:device->brand',this.searchDBValue)
    or
    const {data, error} = await supabase.from('Cards').select('*').eq('device.brand',this.searchDBValue)
    My
    Copy code
    Cards
    .. 
    device:{
     brand..
    }
    ..
  • e

    Ekky

    01/13/2022, 1:47 AM
    @Haba Looks like you're pretty close, have a look here: https://supabase.com/docs/reference/javascript/select#querying-json-data Assuming your table looks like this:
    Copy code
    sh
    # Cards Table
    
    | id      | device                   |
    |---------|--------------------------|
    | 1       | {"brand":"visa"}         |   
    | 2       | {"brand":"mastercard"}   |
    Then your data query should look like this
    Copy code
    js
    // this.searchDBValue = "visa"
    
    const { data, error } = await supabase.from('Cards').select('*').eq("device->brand", this.searchDBValue);
    
    // data = { id : 1, device: "{\"brand\":\"visa\"}" }
    Give that a try maybe?
  • j

    Julien

    01/13/2022, 10:13 AM
    Hello there, I'm looking for example on how to implement ssr auth with nuxt - I couldn't find really helpful doc on SSR auth (agree with @User on this ) @User had the issue some time ago too - dunno if things got a bit clearer ? Do you guy have good ressources / repo example to see how to implement this right ? Thanks !
  • f

    florian-lefebvre

    01/13/2022, 5:28 PM
    Hi ! Hi have only one resource to share: https://github.com/supabase/supabase/tree/master/examples/nextjs-with-supabase-auth to understand how it works. But I remember a few things about a working implementation: 1. You can't use the
    nuxt-supabase
    module or equivalent since you need a server middleware, and nuxt context is not available in it (but you can still inject a supabase client instance from yours) 2. You need a server middleware that works like https://github.com/supabase/supabase/blob/master/examples/nextjs-with-supabase-auth/pages/api/auth.js 3. You need to listen to auth state change using
    supabase.auth.onAuthStateChange
    I don't remember anything else but this should help you to get started
  • f

    florian-lefebvre

    01/13/2022, 5:28 PM
    I think we should write some documentation for ssr auth, or add a working ssr nuxt example
  • j

    Julien

    01/14/2022, 9:03 AM
    Thanks for the ressources! Gonna give it a try and see if I can make something work out off it. And you are true, at least kind of the same repo example with nuxt should be available - and the documentation should be expended on this!
  • d

    darklord

    01/14/2022, 10:35 AM
    Hi there. I am new to supabase and i started integrating with my new Next App. I am having a Public table(named X) with auth_id(foreign key connecting with auth users table). I need to retrive the data from both table X and auth users using relation. Anyone can help on it ?
    s
    • 2
    • 5
  • s

    silentworks

    01/14/2022, 12:03 PM
    Retrieving data from tables
  • m

    Mike92988

    01/14/2022, 2:44 PM
    does anyone know how you would push json into an array in a column while keeping the old json that's already in there? having some trouble with this
    m
    • 2
    • 4
  • j

    jaf

    01/15/2022, 11:23 AM
    Is there a way to run multiple selects on multiple tables with one request? I don't mean related data, completely separate tables
    c
    • 2
    • 2
  • c

    chipilov

    01/15/2022, 2:03 PM
    Multiple selects in a single request
  • d

    DevThoughts

    01/15/2022, 3:51 PM
    I am try to check , if email exists in the data base send magic link to this email. For some reason code not working and i am very new to Supabase, any tips?
    Copy code
    // check if email is valid and exists in database (if not, show error) otherwise send magic link
    
      const [email, setEmail] = React.useState('');
    
      async function handleSubmit(event) {
        event.preventDefault();
       
        if (email.length > 0 && supabase.auth.user()?.email === email) {
          console.log('send magic link');
          return await supabase.auth.signIn({ email });
        } else {
          console.log('invalid email');
          throw new Error('Email not verified');
        }
      }
1...424344...81Latest