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

    Puru

    10/18/2021, 4:25 PM
    It seems there's some sort of rate limiting. Cuz the requests work sometimes, sometimes not
  • s

    silentworks

    10/18/2021, 5:26 PM
    Svelte kit and Supabase
  • u

    ulisses

    10/19/2021, 1:22 PM
    how ca I make an sql table JOIN using supabase-js?
  • s

    Sayan Nath

    10/19/2021, 3:10 PM
    Hi! Can anyone help me how can I achieve the search functionality like Instagram with Supabase Current Code
    Copy code
    let { data, error } = await supabase_connect
          .from("Users")
          .select("name, username, verified, image_url")
          .ilike("name", `%${req.body.name}%`)
          .range(req.body.skip, req.body.limit);
    Tried
    .textSearch()
    but it didn't worked out what actually I wanted.
    s
    • 2
    • 11
  • k

    khacvy

    10/19/2021, 4:35 PM
    any problem with this code ?
  • m

    mikebarkmin

    10/19/2021, 5:08 PM
    No. You need to create a view and query it.
  • s

    Sayan Nath

    10/19/2021, 5:22 PM
    I want to search in this fashion Like my name is Sayan Nath if a user is typing
    Sa
    the people with the beginning of
    Sa
    in name or surname will appear but if anyone searches
    at
    then in the above code I am also appearing
  • s

    silentworks

    10/19/2021, 5:23 PM
    Search based on first part of result
  • c

    chipilov

    10/19/2021, 5:36 PM
    I don't think this is 100% correct, the docs say you can do some joins in Supabase, here is an example: https://supabase.io/docs/reference/javascript/select#query-foreign-tables
  • m

    mikebarkmin

    10/19/2021, 5:49 PM
    That is correct, you can embed resources which are linked by a foreign key, but you can not do arbitrary joins. You can read this for a more detailed explanation https://postgrest.org/en/v8.0/api.html#resource-embedding
  • l

    larryM

    10/20/2021, 3:16 AM
    what would be the best way to handle errors with the realtime client? Im currently trying to use the websockets within a redux reducer and trying to find the best ways to handle any sockets/connection errors
  • j

    jocarrito

    10/20/2021, 3:41 AM
    Hey guys, I'm learning Supabase, just trying to do a simple query and the server returns 200, but empty data
  • j

    jocarrito

    10/20/2021, 3:41 AM
    Copy code
    const { data: users, error, status } = await supabase
                    .from<definitions['users']>('users')
                    .select('*')
  • m

    mikebarkmin

    10/20/2021, 5:42 AM
    You are querying public.users be sure that this table contains data and be sure that the row level security for select is true, when you have rls enabled. I am assuming your are querying on the client. If you are querying on the server with the super key RLS should not be a problem.
  • m

    mikebarkmin

    10/20/2021, 11:02 AM
    It depends on the error. If its is a connection lost error or an error, which could be retried, I would set a timeout and call the connect function again.
  • m

    Mattias

    10/20/2021, 12:39 PM
    Hi @User @User or any other using the node-postgres library
    pg
    ! Would you mind sharing an example of a connection with Supabase. I keep getting
    Error: getaddrinfo ENOTFOUND https://lotsofletters.supabase.co
    My code:
    Copy code
    js
    const pool = new Pool({
      user: 'postgres',
      host: import.meta.env.VITE_SUPABASE_URL,
      database: 'postgres',
      password: import.meta.env.VITE_SUPABASE_ANON_KEY,
      port: 5432,
    });
    
    pool.query('SELECT NOW()', (err, res) => {
      console.log(err, res)
      pool.end()
    })
    s
    s
    • 3
    • 5
  • s

    Sayan Nath

    10/20/2021, 12:58 PM
    Hello! Can anyone let me know how can I use custom SQL query in Supabase JS My SQL Query is like this
    Copy code
    SELECT * FROM "Users" WHERE name LIKE 'Na%' OR name LIKE '%Na' OR name LIKE '%Na%'
  • u

    0xhjohnson

    10/20/2021, 1:03 PM
    The supabase-js lib has “filters” that you can use for this sort of thing https://supabase.io/docs/reference/javascript/or
  • u

    0xhjohnson

    10/20/2021, 1:07 PM
    For your specific example though you just need the one %Na% like()
  • r

    RB_Gaura

    10/21/2021, 4:35 AM
    Anyone know how to fix the sveltekit + supabase routing issue?
    s
    • 2
    • 1
  • s

    silentworks

    10/21/2021, 11:32 AM
    Supabase and svelte kit
  • j

    jonny

    10/21/2021, 6:32 PM
    you can use a series of filters for this. OR https://supabase.io/docs/reference/javascript/like LIKE https://supabase.io/docs/reference/javascript/or also, a good example of a more complex select() with supabase-js https://github.com/supabase/supabase/discussions/1393#discussioncomment-689757
  • m

    M1K3

    10/21/2021, 8:15 PM
    I'm having trouble inserting into a table
    s
    • 2
    • 22
  • s

    stibbs

    10/22/2021, 4:44 AM
    Anyone had this before?
    Copy code
    ts
    const { data, error, count } = await supabase
        .from('jobs')
        .select('id', { count: 'exact', head: true })
        .gt('valid_until', 'now()')
        .neq('closed', 'true');
    Copy code
    bash
    invalid json response body at https://cdylbjsfwtolxghadbnk.supabase.co/rest/v1/jobs?select=id&valid_until=gt.now%28%29&closed=neq.true reason: Unexpected end of JSON input
    
    FetchError: invalid json response body at https://cdylbjsfwtolxghadbnk.supabase.co/rest/v1/jobs?select=id&valid_until=gt.now%28%29&closed=neq.true reason: Unexpected end of JSON input
        at C:\Users\matt\proj\bread\node_modules\node-fetch\lib\index.js:272:32
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
    s
    • 2
    • 10
  • s

    stibbs

    10/22/2021, 4:46 AM
    I don't get the error consistently either... so not sure what's going on
  • j

    jason-lynx

    10/22/2021, 5:51 AM
    what if you replace the last line
    .neq('closed', 'true');
    with
    .is('closed', false)
    ?
  • s

    stibbs

    10/22/2021, 6:39 AM
    I can't tell if it's had an impact (the error isn't consistent)
  • s

    stibbs

    10/22/2021, 7:10 AM
    I'm almost certain this is the cause of my frustration today as well
  • s

    stibbs

    10/22/2021, 7:11 AM
    I'm working with SvelteKit, and my below code reliably results in: 1) A successful initial load 2) A 404 error if you navigate to another page and then back (or click a link to it)
    Copy code
    ts
    <script context="module" lang="ts">
      import type { Load } from '@sveltejs/kit';
    
      export const load: Load = async ({ fetch }) => {
        const countRes = await fetch('/api/count_jobs');
    
        if (countRes.ok) {
          const count = await countRes.json();
          return { props: { jobCount: count } };
        }
    
        return {
          status: countRes.status,
          error: new Error(`Failed to load job count`)
        };
      };
    </script>
    Same behavior occurs if I try different ways of executing the query such as via an rpc...
    Copy code
    sql
    create or replace function count_open_jobs(out job_count integer)
    returns integer
    language plpgsql
    as $$
    begin
      select count(*) into job_count
      from public.jobs
      where valid_until > now()
        and closed = false;
    end; $$
  • s

    stibbs

    10/22/2021, 7:12 AM
    I reliably get the 404 whenever I run it more than once, but I rarely get any feedback indicating an invalid json response
1...272829...81Latest