https://supabase.com/ logo
Join Discord
Powered by
# javascript
  • s

    SickRussel

    06/17/2022, 8:44 PM
    nice, happy to hear that 🙂
  • g

    garyaustin

    06/17/2022, 8:46 PM
    like filters in table UI
  • z

    Zenon

    06/19/2022, 2:11 PM
    I'm getting this error whenever I use supabase in the next.js
    _middleware.js
    file
  • z

    Zenon

    06/19/2022, 2:13 PM
    Copy code
    js
    import { supabase } from "@/config/index";
    import { NextResponse } from "next/server";
    
    export async function middleware(req) {
        const { user } = await supabase.auth.api.getUserByCookie(req);
    
        if (!user) return NextResponse.redirect("/auth/login");
    
        return NextResponse.next();
    }
    supabase
    is simply a supabase client created using the createClient function.
  • z

    Zenon

    06/19/2022, 2:14 PM
    tried searching for solutions on stackoverflow but couldn't find any.. hope someone here can help 🙂
  • g

    garyaustin

    06/19/2022, 2:30 PM
    Probably related to this one: https://discord.com/channels/839993398554656828/843999948717555735/986784635038105640
  • j

    juanzitelli

    06/20/2022, 6:28 AM
    Hey community! Quick question. Is there a way to perform a cascade delete using the JS supabase SDK?
    s
    • 2
    • 5
  • s

    silentworks

    06/20/2022, 6:41 AM
    Cascade delete with supabase-js
  • b

    Big Bird

    06/20/2022, 10:50 AM
    Hi, I have a table called
    shortlisted_talents
    with a column called
    talent_ids
    which is an array of int8's. I understand how I add values to that array. But what if I only want to append / push a single value to it, without overwriting previous values?
  • g

    garyaustin

    06/20/2022, 6:37 PM
    You would have to use an rpc function and do SQL. Array operators: https://www.postgresql.org/docs/current/functions-array.html
    b
    • 2
    • 4
  • j

    jJ

    06/20/2022, 10:59 AM
    Hi all! I am trying to do something that I believe would be quite simple but hit a wall so trying here... I would like to order articles by articles.calendar.start_at (one to one relationship) however it doesn't order them...
    Copy code
    javascript
    let query = supabase
     .from<models.ArticleDocument>('articles')
     .select('*, calendar(start_at)')
     .order('start_at', { foreignTable: 'calendar', ascending: false })
    any ideas how I can do this? Kind regards jJ
  • b

    Big Bird

    06/20/2022, 11:01 AM
    at first sight it looks correct. calendar(start_at) is of timetamp / timetampz data type?
  • j

    jJ

    06/20/2022, 11:02 AM
    timetampz but can change (in development)
  • b

    Big Bird

    06/20/2022, 11:04 AM
    should'nt you use backtics (``) instead of '' for the select statement when referencing a foreign table?
  • b

    Big Bird

    06/20/2022, 11:05 AM
    like this
    Copy code
    let query = supabase
     .from<models.ArticleDocument>('articles')
     .select(`*, calendar(start_at)`)
     .order('start_at', { foreignTable: 'calendar', ascending: false })
  • j

    jJ

    06/20/2022, 11:05 AM
    thanks so much.... will try now
  • b

    Big Bird

    06/20/2022, 11:06 AM
    which ticks to use correctly with sql has captured a lot of dev time, not only with supabase 😅
  • j

    jJ

    06/20/2022, 11:08 AM
    thanks for the tip!! ⭐ ... however it made no difference
  • b

    Big Bird

    06/20/2022, 11:09 AM
    hm then I'm not sure sorry, someone more experienced will have to chime in
  • j

    jJ

    06/20/2022, 11:09 AM
    maybe I'll try different types of relationships, could be a one-to-one limitation
  • j

    jJ

    06/20/2022, 11:09 AM
    seems odd though
  • g

    garyaustin

    06/20/2022, 6:37 PM
    Add data to array
  • r

    rommyarb

    06/21/2022, 4:00 AM
    Hello guys. I have a question about fetching data. Do I still need to use
    limit(1)
    before
    single()
    method? Thx.
    Copy code
    javascript
    const { data } = await supabase
      .from<Profile>('profiles')
      .select()
      .match({ id: userId })
      .limit(1) // is this necessary?
      .single();
    g
    • 2
    • 4
  • g

    garyaustin

    06/21/2022, 4:14 AM
    .limit(1) required for .single() ?
  • secure random number
    g

    garyaustin

    06/21/2022, 4:20 PM
    Yes you would use Postgres SQL in a function, then call that function with .rpc().
    u
    • 2
    • 3
  • g

    garyaustin

    06/21/2022, 4:20 PM
    secure random number
  • d

    Devr

    06/22/2022, 11:16 AM
    Hey there ! am using svelte-kit for frontend stuff ..,Can we use supabase queries like .insert(),.select(),etc in endpoints or hooks (these are basically functions which are used for data fetching or loading .., it runs on server side) Will it make any difference? as it runs on server (Sorry if this sounds noob thing, am new to supabase and databases stuffs..,)
    s
    • 2
    • 2
  • s

    silentworks

    06/22/2022, 11:51 AM
    SvelteKit with Supabase
  • h

    hatton

    06/22/2022, 5:19 PM
    Hi, we're just getting started, and we're stuck. We're trying to create our first edge function, but cannot
    createClient
    , and do not get a useful error back.
    Copy code
    import { serve } from "https://deno.land/std@0.131.0/http/server.ts";
    import { createClient } from "https://deno.land/x/supabase@1.3.1/mod.ts";
    
    serve(async (req) => {
      try {
        const supabase = createClient(
          Deno.env.get("SUPABASE_DB_URL")!,
          Deno.env.get("SUPABASE_ANON_KEY")!
        );
    
        return new Response("Successfully created client");
      } catch (error) {
        return new Response(
          JSON.stringify({
            error_name: error.name,
            error_message: error.message,
            stack: error.stack,
          })
        );
      }
    });
    We then test this with
    supabase functions deploy report-font-use --no-verify-jwt
    curl -L -X POST 'https://<OURPROJECTREF>.functions.supabase.co/report-font-use'
    The result is
    Copy code
    {
      "error_name": "TypeError",
      "error_message": "Cannot read properties of undefined (reading 'href')",
      "stack": "TypeError: Cannot read properties of undefined (reading 'href')\n    at getParameterByName (file:///src/main.ts:389:37)\n    at new GoTrueClient (file:///src/main.ts:869:61)\n    at new SupabaseAuthClient (file:///src/main.ts:1377:9)\n    at SupabaseClient._initSupabaseAuthClient (file:///src/main.ts:3130:16)\n    at new SupabaseClient (file:///src/main.ts:3070:26)\n    at createClient (file:///src/main.ts:3176:12)\n    at Server.<anonymous> (file:///src/main.ts:3180:9)\n    at Server.#respond (file:///src/main.ts:110:43)\n    at Server.#serveHttp (file:///src/main.ts:131:26)"
    }
    As I say, pretty stuck. Can someone point out what we're missing?
    g
    • 2
    • 2
  • g

    Günhan

    06/23/2022, 7:50 AM
    Hey guys, how can i use ORDER BY RANDOM() with supabase-js client?
1...646566...81Latest