https://supabase.com/ logo
Join Discord
Powered by
# help
  • r

    ReactingMe

    03/11/2022, 5:29 AM
    Hey guys, can you help me figure this out - I'm a supabase newbie. So, I am trying to save data that I fetched from an api to my supababse database (using Nextjs), but can't tell where to plug in my supabase related code to 'Insert' the data. Here is what my code looks like
    Copy code
    export async function getServerSideProps({ req }) {
      //Base Url
      const gBaseUrl = 'https://www.googleapis.com/youtube/v3';
    
      //Supabase related
      //Insert many rows
    
      // const { data, error } = await supabase
      // .from('table')
      // .insert([
      //   { some_column: 'someValue' },
      //   { some_column: 'otherValue' },
      // ])
    
      const channelID = [];
    
      for (const channel of channelList) {
        const channelData = await fetch(
          `${gBaseUrl}/channels?part=snippet,contentDetails,statistics&id=${channel.channelID}&key=${process.env.YOUTUBE_API_KEY}`
        ).then((res) => res.json());
        channelID.push(channelData.items); // Need to save "channelData.items" coming from YoutubeAPI to the database.
      }
    
      //Return data
      return {
        props: {
          channelID,
        },
      };
    }
    What to do?
    n
    • 2
    • 3
  • i

    Ic3m4n

    03/11/2022, 6:20 AM
    Hi, I get a 522 CF error page instead of data when I request data from my DB. Happens since yesterday and worked before. Can someone please help?
    n
    d
    • 3
    • 4
  • f

    fig.newton

    03/11/2022, 8:11 AM
    Hey! I’ve got a question that I’m a bit stumped on. My end goal is to query a field based on the value of an item inside an array -- nested within a JSONB object. Here’s an example: Table candidates
    Copy code
    | uuid |                       data                       |
    -----------------------------------------------------------
    | cafe | {"foo": "bar", "applications": [{"job": "baz"}]} |
    So far this plain SQL query works:
    Copy code
    SELECT c.uuid, c.data
    FROM candidate as c
    WHERE c.data->'applications' @> '[{"job": "baz"}]'::jsonb
    as does this:
    Copy code
    SELECT c.uuid, c.data
    FROM candidate as c
    WHERE EXISTS ( SELECT TRUE FROM jsonb_array_elements(data->'applications') AS apps WHERE apps->>'job' IN ('baz') )` but I’m pretty stumped about translating this to a Supabase query. The PostgREST docs do mention that these JSON operations should be possible, but it’s not clear how to safely construct this query. The only thing that comes to mind is something like "'[{\"job\": \"" + job_id_here "\"}]'" 😦
    n
    • 2
    • 1
  • g

    georgeaffield

    03/11/2022, 9:19 AM
    Hey guys, I am trying to connect to supabase postgres db using prisma & I am getting the following error when running prisma migrate. I have looked at a few tutorials on youtube and they all seem to be doing the same thing as me. Any idea why I am getting this issue? I thought it might be to do with PgBouncer but not entirely sure. I have had a look at these docs: https://www.prisma.io/docs/guides/performance-and-optimization/connection-management/configure-pg-bouncer https://www.prisma.io/docs/concepts/components/prisma-migrate/shadow-database#shadow-database-user-permissions The error I am getting is the following: db error: FATAL: unexpected response from login query 0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history at migration-engine\connectors\sql-migration-connector\src\flavour\postgres.rs:363 1: migration_core::state::DevDiagnostic at migration-engine\core\src\state.rs:178 My env file DATABASE_URL=postgres://postgres:mypassword@my.database.supabase.co:6543/postgres Any ideas? Cheers 🙂
    n
    t
    • 3
    • 7
  • p

    pkovzz

    03/11/2022, 10:11 AM
    hi! how can i get a new access token on server side? i did not find anything about the topic 😮
    n
    o
    • 3
    • 4
  • a

    ak4zh

    03/11/2022, 3:04 PM
    I am trying to implement auth in my svelte app. I see few example but they over complicate it with multiple stores and hooks and getSession. How does supabase auth actually works. I see when I call
    auth.signIn()
    supabase stores the session in the browser local storage. Now does the client check that localStorage every-time a request is being made and add the user in the api calls. What happens when the session in localStorage has expired and my app tries to make api call? Will supabase just keep working and stop adding the user info in api calls and does not remove the session stored in local storage? Or it checks during every api call if session is still valid and if valid it adds user else deleted the session from local storage so my apps knows thatbuser is logged out and I redirect them to login page. In my app I am simply accessing the localStorage to know if user is logged in, when I call
    auth.signOut()
    supabase removed the localstorage so login logout seems to work already without over complicating the setup.
    n
    • 2
    • 1
  • c

    Colin

    03/11/2022, 3:50 PM
    Hi there! I added user auth to my application and it's working like a charm! The only thing that is odd is that it shows
    Invalid Date
    for created/last sign in, but if I log these values it seems fine, what am I missing? 🤔
    n
    d
    s
    • 4
    • 13
  • m

    Mopsior

    03/11/2022, 4:41 PM
    Hi there! i'm selfhosted supabase by docker. Docker always spams error
    "supabase-realtime  | 2022-03-11 16:38:34.261 [error] Postgrex.Protocol (#PID<0.232.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (db:5432): non-existing domain - :nxdomain"
    .
    n
    s
    +2
    • 5
    • 55
  • s

    Shneor

    03/11/2022, 5:07 PM
    Hey 👋🏻 We are working on application and we want every field input to be save to Supabase DB automatically. Is it require "real time db" or should we fire query (with every change?)?
    n
    s
    • 3
    • 3
  • a

    Anorok

    03/11/2022, 8:11 PM
    Hey everyone! Currently using Supabase in a Nextjs app. I'm trying to find some example code utilizing the service_key in order to bypass RLS (Building an admin panel to view/edit all profiles). I've found reference to it, and a warning to only use it serverside. I'm supanew. Does anyone have an example of using a service key to display all profiles?
    n
    o
    • 3
    • 18
  • j

    justinjunodev

    03/11/2022, 8:33 PM
    Question regarding best practices for multiple column updates in a single row. Context: Say I have a
    social
    table that includes a row for each
    user
    . Within that row are columns for several social networks (twitter, youtube, twitch, whatever, etc.). Question: Chances are most users will not have every social network listed, but the form will include inputs for each social column available. That said, is there a specific way I should structure the update query? Or is it standard to submit all the fields and include fallback values with the existing state to catch those that are not in use/ okay as is? *Example: Is this standard/ okay? *
    Copy code
    const { data, error } = await supabase
      .from('social')
      .update(
        { twitter: newStateValue || prevStateValue},
        { youtube: newStateValue || prevStateValue}, 
        { twitch: newStateValue || prevStateValue}
      )
      .eq('user', user.id)
    n
    s
    • 3
    • 3
  • d

    DanMossa

    03/12/2022, 12:53 AM
    Having trouble downloading the photos I've uploaded to storage. When uploading
    Copy code
    final StorageResponse<String> res = await _supabase.client.storage.from('profile-pictures').upload('uuid/0', file,
            fileOptions: const FileOptions(upsert: true));
        return res.data;
    res.data shows
    profile-pictures/uuid/0
    When I then go to download that file
    Copy code
    final  StorageResponse<Uint8List> res = await _supabase.client.storage.from('profile-pictures').download("uuid/0");
        return res.data;
    res.data says 404
    n
    • 2
    • 4
  • b

    BakaPresident

    03/12/2022, 3:14 AM
    Can anyone have a look at this database diagram before i begin to port it over to supabase. I've only learnt a bit of database so please bear with me. https://dbdiagram.io/d/622af5c061d06e6eade2f69e I'm trying to make a queue system where user can just press a button and they would be in queue to get an appointment to the doctor for the day
    n
    s
    • 3
    • 7
  • c

    cardyet

    03/12/2022, 3:43 AM
    Hey all, I posted this to r/supabase but maybe here is a bit more appropriate. I'm a bit stuck running a cron job query and sending those results to an API endpoint
    Copy code
    select
      cron.schedule(
        'webhook-every-day', -- name of the cron job
        '1 0 * * *', -- every day at 12:01am
        $$
        -- declare variable
        declare
        results setof events
        -- start::query reminders table
        RETURN QUERY SELECT title, date
        INTO results
        FROM events
        WHERE CAST(date AS DATE) = NOW()::DATE
        -- end::query
        select status
        from
          http_post(
            'https://api.com/',
            results, -- payload as an array of rows?
            'application/json'
          )
        $$
      );
    This produces an error at or near
    setof events
    n
    d
    • 3
    • 4
  • a

    AmusedGrape

    03/12/2022, 3:48 AM
    bit of a doozy here; i'm trying to use an iframe to have universal auth on all related sites to my project (so not every site associated has to have its own login page, just uses the auth server), and supabase cant seem to get the session from localstorage through the iframe, however if i go to the page in my browser normally, it works just fine. is this something with supabase/gotrue or javascript (or my code)? thanks!
    n
    • 2
    • 5
  • a

    ak4zh

    03/12/2022, 8:44 AM
    I have a table with id as int8 primary key. I have inserted 10 rows from SQL editor, now when I use supabase-py to insert it does not use the correct increment on insert, it seems to not know about already inserted columns and starts generating primary key from 1 instead of 11.
    n
    s
    • 3
    • 7
  • e

    ekansh005

    03/12/2022, 10:46 AM
    Hi Guys, Can someone please help on this?
    n
    o
    • 3
    • 4
  • s

    Señor Bruno

    03/12/2022, 9:04 PM
    Hi. How do I use formidable with supabase + nextjs to upload a file?
    n
    • 2
    • 3
  • c

    cliffordfajardo

    03/12/2022, 11:59 PM
    How can I filter on multiple columns values? Docs don't show that type of example I think? https://supabase.com/docs/reference/javascript/using-filters#applying-filters regular sql
    Copy code
    FROM cities SELECT * WHERE zipcode = '95555' AND state = 'California'
    supabase
    Copy code
    const { data, error } = await supabase
      .from('cities')
      .filter('zipcode', 'eq', 'category)
    n
    g
    s
    • 4
    • 15
  • g

    girishso

    03/13/2022, 5:56 AM
    I'm getting CORS error when calling rest apis from Elm, the same api works just fine in React app using with supabase js lib. I added header
    x-client-info: supabase-js/1.31.1
    in Elm app to see if it makes any difference. Any hints?
    n
    c
    • 3
    • 5
  • m

    Mopsior

    03/13/2022, 7:57 AM
    Hi, someone can help me ^^^?
    n
    o
    • 3
    • 4
  • y

    Yänz

    03/13/2022, 10:45 AM
    Hello everyone, I want in my app. (AppGyver) make a self-service in which the user can change his password. I can't find a tutorial where I can change my password with Postman, for example. How should I do that? Thanks very much Jens
    n
    c
    r
    • 4
    • 11
  • g

    gralp

    03/13/2022, 12:32 PM
    how do I set an expiry on rows?
    n
    a
    d
    • 4
    • 9
  • a

    Apfelsaft

    03/13/2022, 1:47 PM
    Is it possible to run queries on a table inside a function without triggering a subscription listener on the client side?
    n
    • 2
    • 1
  • d

    d33pu

    03/13/2022, 2:00 PM
    Hello everyone, I am having hard time to work with cron job I am trying to run this but it seems it doesn't return json at all.
    n
    o
    • 3
    • 5
  • n

    Needle

    03/13/2022, 2:00 PM
    Hello @d33pu! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
    /title
    command! We have solved your problem? Click the button below to archive it.
    o
    • 2
    • 3
  • d

    d33pu

    03/13/2022, 2:02 PM
    Copy code
    select
      cron.schedule(
        'webhook-every-minutex', -- name of the cron job
        '* * * * *', -- every minute
        $$
        select content::json->'results'
    from http_get('https://swapi.dev/api/people');
        $$
      );
    thats the code I am trying to run but doesn't work If I manually run the select statement it returns the json results any help is highly appreciated 🙏
    n
    o
    • 3
    • 4
  • n

    Needle

    03/13/2022, 2:02 PM
    Hello @d33pu! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
    /title
    command! We have solved your problem? Click the button below to archive it.
    o
    • 2
    • 3
  • l

    Ludvig

    03/13/2022, 3:01 PM
    I want to learn how to build superb data models in supabase or prisma to use with postgres. Where can I find some good resources on this? Anyone has a link?
    n
    o
    • 3
    • 10
  • a

    Amatewasu

    03/13/2022, 5:43 PM
    Hi folks! I am quite new at using supabase. I am wondering how I should access my users email on the server-side? I created a
    profiles
    table with data such as the firstname & lastname. But then I would like to retrieve a user email from its profiles.id. Is it possible. How would you do? Thanks a lot!
    n
    s
    • 3
    • 6
1...242243244...316Latest