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

    Kylar

    09/27/2021, 2:51 PM
    I used to have a firebase-redux stack, are there any specific questions I can help with?
  • a

    Adnane

    09/27/2021, 2:54 PM
    I just need a tutorial to get my head around it 🙂
  • l

    larryM

    09/27/2021, 5:20 PM
    has any one used @supabase/realtime-js in an electron environment? we're trying to use it an a native dependency but run into issue with when running electron-rebuild with node-gyp
  • l

    liljamesjohn

    09/27/2021, 5:37 PM
    Is it possible to delete multiple rows from the same table?
  • l

    liljamesjohn

    09/27/2021, 5:37 PM
    I.e I have an array of ids = [5,6,7,8]... Delete the rows with id's that match, but without a lopp of any kind i.e Batch delete
  • g

    garyaustin

    09/27/2021, 10:21 PM
    from the docs const { data, error } = await supabase .from('cities') .delete() .in('name', ['Rio de Janeiro', 'San Francisco'])
  • k

    Kylar

    09/28/2021, 10:50 AM
    What we did is getting the total count of items and then set a realtime listener for item added. That way we'd set an initial loader until the listener had fired for all the items, and then reference the items by id and always have in the store the updated item
  • b

    bokolesnik

    09/28/2021, 1:39 PM
    is possible to use
    .query('SELECT * FROM Table LIMIT 100;')
    ?
  • s

    Scott P

    09/28/2021, 1:40 PM
    Running SQL via the JS lib? No, not directly.
  • b

    bokolesnik

    09/28/2021, 2:02 PM
    'no' for both libs?
  • s

    Scott P

    09/28/2021, 2:04 PM
    Postgrest-js is part of supabase-js. If you want direct querying from the database, the
    pg
    library can do it.
  • b

    bokolesnik

    09/28/2021, 2:12 PM
    having an issue with js lib. can't select items as before (5k) per query. 300k records in the DB, query
    .limit(500)
    works fine, but
    .limit(1000)
    isn't. limit in Settings is 10k. supabase UI and SQL sandbox work correctly
  • j

    jaded

    09/28/2021, 2:32 PM
    hi team, i am a novice and have started a new project with react and supabase. i am currently trying to make a supabase call to work. it is working but it somehow doesnt return any data even tho my table has 2 rows in it? any idea?
  • j

    jaded

    09/28/2021, 2:35 PM
    Copy code
    const [produktos, setProduktos] = useState([])
    
        useEffect(() => {
            getProduktos()
        }, [])
    
        async function getProduktos() {
            const { data } = await supabase
                .from('products')
                .select()
            setProduktos(data)
            console.log("data: ", data)
        }
  • j

    jaded

    09/28/2021, 3:03 PM
    this has been solved thanks. it was
    Copy code
    RLS
    blocking me
  • j

    jaded

    09/28/2021, 3:04 PM
    does supabase select have support for pagination?
  • g

    garyaustin

    09/28/2021, 3:12 PM
    .range(low,high) you can also return a count of matches
  • s

    stibbs

    09/29/2021, 1:38 PM
    Your API needs the headers/cookie so that supabase can see the user is authenticated
  • l

    liljamesjohn

    09/29/2021, 1:42 PM
    I don't suppose there are any examples for that?
  • s

    stibbs

    09/29/2021, 9:05 PM
    I'm not sure the 'correct' way of doing this, but I added a
    handleAuthChange
    function
    Copy code
    js
    async function handleAuthChange(event, session) {
      await fetch('/api/auth', {
        method: 'POST',
        headers: new Headers({ 'Content-Type': 'application/json' }),
        credentials: 'same-origin',
        body: JSON.stringify({ event, session })
      });
    }
    and added it to my context provider
    Copy code
    js
    useEffect(() => {
      const session = supabase.auth.session();
      setSession(session);
      handleAuthChange({ event: 'SIGNED_IN' }, session); // NEW
      setUser(session?.user ?? false);
      const { data: authListener } = supabase.auth.onAuthStateChange(
      async (event, session) => {
        setSession(session);
        handleAuthChange(event, session); // NEW
        setUser(session?.user ?? false);
      }
    );
    api/auth.js
    Copy code
    js
    import supabase from '@utils/supabase';
    
    const AuthCookie = async (req, res) => {
      supabase.auth.api.setAuthCookie(req, res);
    };
    
    export default AuthCookie;
    and then ensure the cookie is used by the api by adding
    Copy code
    js
    import supabase from '@utils/supabase';
    
    const YourApiHere = async (req, res) => {
      supabase.auth.setAuth(req.cookies['sb:token']);
      ...
    };
  • l

    liljamesjohn

    09/29/2021, 9:07 PM
    I already have my with setup with a route via API for setting the cookie. My problem is then running database queries via the api
  • s

    stibbs

    09/29/2021, 9:09 PM
    What RLS rules did you add?
  • s

    stibbs

    09/29/2021, 9:12 PM
    You don't do anything special to work with a table that has RLS enabled.
    await supabase.from('my_table').select('*');
    will work with or without RLS enabled, but if RLS is enabled your call of the api needs to have the cookie
  • s

    stibbs

    09/29/2021, 9:13 PM
    Do you get an error when making the api call?
  • l

    liljamesjohn

    09/29/2021, 9:34 PM
    Yeah, hence me trying to figure out how to use the cookie with supabase via api. I have both the “authenticated” and “user id” templates.
  • s

    seufernandez

    09/29/2021, 9:38 PM
    Hey guys, have anyone used CORS in Next js API?
  • s

    stibbs

    09/29/2021, 11:32 PM
    Can you share these templates? I'm not sure what you mean
  • l

    liljamesjohn

    09/29/2021, 11:33 PM
    When making RLS rules. You are given a choice to make custom ones or a template. But that isn’t the issue. I am trying to interact with supabase db via /api instead of client side.
  • s

    stibbs

    09/29/2021, 11:36 PM
    Oh in the UI, right. Can you share where you set the cookie + your API code?
  • s

    stibbs

    09/29/2021, 11:46 PM
    You need to add the cookie to your headers, and in your API call
    supabase.auth.setAuth(req.cookies['sb:token']);
    before executing your db call
1...222324...81Latest