https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • Doing JOIN operations in Swift?
    k

    kevlust

    02/22/2023, 7:30 PM
    Hi all! In my project, I have a “users” table and a “follows” table (which has foreign keys that reference user ids in the “users” table). In order to fetch all followers of a user (along with their username), I need to do a JOIN between both of these tables. However, I haven’t been able to find a join() function or anything similar in the Swift package. I know the Swift package isn’t officially supported by Supabase, but I figured this is a very common issue that someone in this community probably has figured out. So my question is: using the Supabase Swift package, how can I perform a JOIN using these two tables? If not possible, is there a way for me to inject my own raw SQL query string to be executed? Thanks in advance 🙏
    g
    • 2
    • 4
  • pg_vector and blog post about storing openai embeddings
    g

    gorbypark

    02/22/2023, 7:34 PM
    Hey folks, I'm following along with the blog post "Storing OpenAI embeddings in Postgres with pgvector" and I'm running into some trouble. I managed to get to the point where I have a few embeddings for "documents" in a pg_vector column, I have the RPC
    match_document
    and I have an edge function taking in the search query, converting it an emedding and (attempting) to find matches using
    match_document
    . My issue is the edge function always just returns
    null
    (but status 200) and in the PostGRES logs I can see "column reference "id" is ambiguous". I'm not quite sure where I'm going off the rails. Heres my match documents rpc:
    Copy code
    sql
    create or replace function match_documents (
      query_embedding vector(1536),
      similarity_threshold float,
      match_count int
    )
    returns table (
      id bigint,
      content text,
      similarity float
    )
    language plpgsql
    as $$
    begin
      return query
      select
        id,
        content,
        1 - (documents.embedding <=> query_embedding) as similarity
      from documents
      where 1 - (documents.embedding <=> query_embedding) > similarity_threshold
      order by documents.embedding <=> query_embedding
      limit match_count;
    end;
    $$;
    g
    z
    • 3
    • 5
  • Is it possible to use Supabase Auth, but use MongoDB as the database?
    b

    brettshep

    02/22/2023, 7:37 PM
    I'm wanting to use MongDB as my primary DB simply because I have much more experience with NoSQL DBs. From what I understand it's possible to run Supabase Auth standalone, so I was wondering how I could go about doing this while using Mongo as it's DB. Is such a thing possible?
  • How does security on the column level work?
    m

    magnusbee

    02/22/2023, 7:45 PM
    As someone new to SQL/PostgreSQL/Supabase I don’t understand how security on the column level works. My understanding is that any user who pass the RLS check (e.g., by being logged in) can update any column even outside the application they are logged into, by for example sending a request through Postman with their JWT token. Therefore, any data that the user shouldn’t be able to update (such as a Stripe customer id, the payment status of an order etc.) should be stored in separate private tables that can only be accessed from a server using a service role key. Is this correct, or is there another or better way to prevent certain columns from being updated? Also, does this mean that standard fields in tables like
    id
    (primary key) and
    created_at
    are vulnerable to being changed by a user that has access to other data in that row?
    g
    • 2
    • 7
  • How to edit shared_preload_libraries and add pg_stat_statements ?
    p

    Pisti2010

    02/22/2023, 8:57 PM
    I've been trying to get pg_stat_statements to show data for my queries but i keep getting the error to add pg_stat_statements to the shared preload libraries. I have attempted to edit the postgres.conf file but i don't know how i can access it. Is there a way to edit this file manually or is it fully managed by supabase?? I've already tried dropping and re-creating the pg_stat_statements extension, restarting my project, among other attempts at fixing the issue.
    g
    • 2
    • 9
  • query.in() not excluding results
    m

    maglev

    02/22/2023, 9:15 PM
    Hi, I have a base query for a table of contacts and I'm using query.in() to only return the contacts with 'Retail' in the industry column. However the query returns other results besides 'Retail', is this because query.in() doesn't add an 'and' condition to the original query but an 'or'? Thanks.
    o
    g
    d
    • 4
    • 32
  • UTF-8
    e

    eho.ai-studio.23

    02/22/2023, 10:15 PM
    #1006358244786196510 Hi, we have the following issue: On table 'Conversations', there is a column 'convo_history' defined as an Array of Strings. This array of Strings contains multi-lingual UTF-8 encoded strings. We found that when saving a string such as : "Great, can you use Japanese to describe Quantum Computing? -xxxx- 量子コンピューティングとは、データを安全に保管し、ネットワーク上で共有するための分散型のコンピューター技術です。この技術を使用することで、取引を安全に行うことができ、取引履歴を追跡したり、不正な取引を防止したりすることが可能です。 " the string is saved as : "Great, can you use Japanese to describe Quantum Computing? -xxxx- u91cfu5b50u30b3u30f3u30d4u30e5u30fcu30c6u30a3u30f3u30b0u3068u306fu3001u30c7u30fcu30bfu3092u5b89u5168u306bu4fddu7ba1u3057u3001u30cdu30c3u30c8u30efu30fcu30afu4e0au3067u5171u6709u3059u308bu305fu3081u306eu5206u6563u578bu306eu30b3u30f3u30d4u30e5u30fcu30bfu30fcu6280u8853u3067u3059u3002u3053u306eu6280u8853u3092u4f7fu7528u3059u308bu3053u3068u3067u3001u53d6u5f15u3092u5b89u5168u306bu884cu3046u3053u3068u304cu3067u304du3001u53d6u5f15u5c65u6b74u3092u8ffdu8de1u3057u305fu308au3001u4e0du6b63u306au53d6u5f15u3092u9632u6b62u3057u305fu308au3059u308bu3053u3068u304cu53efu80fdu3067u3059u3002" We are using Python code to fetch data. Please help us resolve this issue.
    g
    • 2
    • 6
  • Too many "remaining connection slots are reserved for non-replication superuser connections" errors
    j

    jcurbelo

    02/22/2023, 10:22 PM
    Hi. we have only a single service API (long running service) built with nest.js using prisma as singleton and we are constantly getting the following error:
    Copy code
    Error: db error: FATAL: remaining connection slots are reserved for non-replication superuser connections
    any ideas what could we doing wrong? i followed these steps: https://docs.nestjs.com/recipes/prisma and still get that error even when executing migrations
    g
    • 2
    • 3
  • How to turn off default email templates
    a

    aunum

    02/22/2023, 10:46 PM
    Is there a way to turn off the email templates that get sent out after sign up? I would like to handle these transactional emails separately. I don't see an option to turn them off in the backend.
  • Failed to delete user
    c

    caseycrogers

    02/22/2023, 11:38 PM
    When I try to delete a test user I get the following error:
    Copy code
    dart
    Failed to delete user: update or delete on table "users" violates foreign key constraint "objects_owner_fkey" on table "objects"
    I get that this means that this user has uploaded one or more files to storage, but I have no idea which one(s). Is there any easy way to query for this so I can find them and delete them?
    g
    • 2
    • 6
  • Confused on logic for authentication in static vanilla JS web app
    w

    whiskeywizard

    02/22/2023, 11:49 PM
    Hi, I'm having trouble getting my head around how best to handle authentication in a simple static html, vanilla JS web app. Everything is sort of working, but it feels messy. In each page that requires authentication, I check if (supabase.auth.session()), and if not, redirect back to the login page. This works, except if the user logs in using oAuth, in which case my above code fires before Supabase creates the session and it redirects back to the login page. So to handle that, I'm checking if the login method is Oauth using a custom URL parameter passed through, and waiting for onAuthStateChange before checking supabase.auth.session(). That works, but feels messy. Is there a better way to handle everything cleanly? Separately, my approach doesn't work for password reset emails, since they also log the user in asynchronously so I'd have to write a condition for those. Any help is appreciated. Thank you.
    g
    • 2
    • 8
  • Supabase hidden schema
    k

    konga

    02/23/2023, 12:20 AM
    What is the schema for the user tables and other hidden tables for Supabase? I'm getting some weird errors where I can't call unique on email anymore.
    j
    • 2
    • 3
  • Self-Hosted connect to s3 bucket
    p

    pasha_dee

    02/23/2023, 12:31 AM
    Hey guys... find it very unclear on how you would connect (point) a docker self-hosted setup to use a s3 bucket for storage .. no samples in the .env or anywhere else that I can find, has anyone done this if so would you be so kind as to share what needs to happen, would be very grateful 🙂
    m
    • 2
    • 7
  • How to export firebase subcollections to migrate to supabase
    d

    DarkPhoenix

    02/23/2023, 1:03 AM
    I am trying to export my firestore data using firebase to supabase migration tool. It is not working for subcollections https://github.com/supabase-community/firebase-to-supabase
    g
    • 2
    • 5
  • Account Preferences help
    n

    Nyx

    02/23/2023, 2:11 AM
    G'day, hoping for a little help. I signed up for a pro account, the $25 per month, well, at least I think i did, but I can't see anything in my Supabase account that suggests the sign up has gone through. I can see the money is out of my account. I also can't seem to find details in the docs regarding how many projects you get under the pro subscription. It seems like you get 1, is that right?
    s
    • 2
    • 2
  • Do synchronous requests from the client to save data risk data integrity issues?
    k

    Kellen Mace

    02/23/2023, 3:23 AM
    DB Tables Let's say I have database tables for
    people
    ,
    movies
    and
    colors
    . I also have a
    person_movies
    table to keep track of a person's favorite movies, and a
    person_colors
    table to keep track of their favorite colors. Data Requirements My web app forces users to enter at least one movie and one color as their favorites. It should be impossible for a user to exist on the site who does not have a favorite movie or color saved. Scenario A user with favorite movies "A" and "B" and favorite colors "green" and "blue" logs into my web app. They remove their previous favorites and set "C" and "D" as their new favorite movies, and "yellow" and "orange" as their new favorite colors, and hit the button to save the data. The movies and colors they entered don't exist in the
    movies
    and
    colors
    tables yet, so they need to be inserted. To handle this, I use the supabase-js client. I fire off these requests: 1. Insert movies "C" and "D" into the
    movies
    table 2. Insert colors "yellow" and "orange" into the
    colors
    table 3. Remove the old usermovies relationships from the
    person_movies
    table 4. Remove the old usercolors relationships from the
    person_colors
    table 5. Save the new usermovies relationships to the
    person_movies
    table 6. Save the new usercolors relationships to the
    person_colors
    table Performing these six operations works great for making the changes needed, and I can even run some of them in parallel so they don't take long. Data Integrity Concern What if the user's network connection drops out or their browser crashes between operations 4 & 5? That could result in data integrity issues, since my app would have performed the operations necessary for removing the old usermovies and usercolors relationships, but it never had a chance to add the new, required relationships. How should I address this problem?
    g
    j
    • 3
    • 6
  • Does the phone auth support receiving OTP via other channels (besides SMS)?
    c

    ChinKX

    02/23/2023, 3:55 AM
    Hi. I am trying to start a new project and plan to use the phone auth for my users to log in to the app. From the official documentation, I think it only mentions receiving OTP via SMS. However, I am worried that my user cannot receive the OTP via SMS because of phone signal issues or etc. Thus, I would like to seek advice on what can I do in this case e.g. can I send the OTP to the user via Whatsapp. Note that I need the user to verify their mobile no. as this is very important for my app and that's why I plan to use phone auth. Thanks for helping in advance!
    s
    • 2
    • 5
  • supabase not giving real time table updates to my next app!
    n

    NJ™

    02/23/2023, 6:07 AM
    I have made a join between my auth schema and public users table. As I delete the user from both tables the change is not reflecting in my next app until I refresh the page. Has anyone had this happen to them before? #1006358244786196510
    s
    • 2
    • 4
  • How can I download all existing files in the bucket
    r

    Revaycolizer

    02/23/2023, 7:25 AM
    As I used this below
    Copy code
    const getPic = async () => {
          try {
            const { data: projects, error } = await supabase.storage
              .from("profiles")
              .download () 
            if (error) throw error;
            src.value = URL.createObjectURL(data)
          } catch (error) {
            error.value = error.message;
            setTimeout(() => {
              error.value = false;
            }, 5000);
          }
        };
    But it's not working
    m
    g
    • 3
    • 26
  • Phone login and google login doesnt work together
    k

    kresimirgalic

    02/23/2023, 8:05 AM
    Hello community, I have a problem with login. The idea is to have phone auth and google auth. First step is to authorise user with phone, and went him through the setup profile where he will enter his email and store it. Second step is to logout and try with google (same email) but what i got is database error saving new user, but in this case we dont need to save new user, we just need to merge the same email provided in setup profile. I tried to use this code to confirm user and add email to auth
    Copy code
    await supabaseAdmin.auth.admin.updateUserById(res.id, {
            email_confirm: true,
            email: res.email,
            email_confirmed_at: new Date().toISOString(),
            user_metadata: {
              is_onboarded: true,
            },
          });
    Also for debugging purposes i tried to create a basic email signup and try with that and google login and it worked. So, it obviously the problem somewhere in verifying the user email and confirmation in the setup profile where i am doing the code above. Can anyone help?
  • pg_cron: function to_timestamp(text) does not exist
    j

    jinsley8

    02/23/2023, 8:13 AM
    I have a Postgres function setup that I'm trying to run with a cron job using
    pg_cron
    . expiry column is a text string in UNIX format. I want to find the rows with expiry date before current date. This query works:
    SELECT to_timestamp('1677129809')::timestamp < now() AND order_status = 'Fillable' FROM orderbook_direct;
    Now this is my function but when pg_cron tries to run it, it returns an error:
    function pg_catalog.to_timestamp(text) does not exist.
    Why is
    pg_cron
    not able to run to_timestamp() ? Or is there a better way to compared a unix time string with current date?
    Copy code
    sql
    CREATE OR REPLACE FUNCTION check_expiry_and_update_status_direct_listing()
    RETURNS VOID
    AS $$
    DECLARE
        row record;
    BEGIN
        FOR row IN SELECT * FROM orderbook_direct WHERE pg_catalog.to_timestamp(expiry)::timestamp < now() AND order_status = 'Fillable' LOOP
            UPDATE orderbook_direct SET order_status = 'Expired', nonce = NULL, signature = NULL, order_valid = false WHERE id = row.id;
        END LOOP;
    END;
    $$ LANGUAGE plpgsql;
    This is my cron job:
    Copy code
    sql
    SELECT cron.schedule('cleanup-expired-direct','*/5 * * * * *', 'SELECT check_expiry_and_update_status_direct_listing()');
    g
    • 2
    • 1
  • How to push local changes to remote?
    n

    nicetomytyuk

    02/23/2023, 8:33 AM
    I've just started using supabase, I'm using the local environment for the development with supabase-cli, after I've built all my schemas and created my edge-functions, I was trying to push all of this to my remote project. After I've linked the project with
    supabase link --project-ref <project-id>
    I created a database migration with
    supabase db diff --use-migra create_database -f create_database
    and then tried to push all the changes with
    supabase db push
    but instead I get this error: > Error: supabase_migrations.schema_migrations table conflicts with the contents of supabase\migrations.; Expected version 20230222145918 but found migration 20230223081033_create_database.sql at index 0. > Try rerunning the command with --debug to troubleshoot the error. While pushing the functions I had no problems.
    s
    • 2
    • 42
  • I can only insert one note getting error?
    d

    Dembe

    02/23/2023, 8:49 AM
    first works, but when I want to insert one more, I get error message
    Copy code
    message: duplicate key value violates unique constraint "guestbook_pkey"
    `
    what is the problem really? tried to check in supabase what it is, but can't figure it out.
    Copy code
    js 
     const add = async () => {
        const { error } = await supabase.from("guestbook").insert({
          body: text,
          id: data?.user?.id,
          name: data?.user?.name,
        });
        if (error) {
          console.log(error);
        }
      };
    s
    • 2
    • 1
  • Infinite loop using sveltekit auth helper
    a

    Amr

    02/23/2023, 9:48 AM
    I have this code in my
    hooks.server.ts
    which causes infinite redirect loop when the user is logged in!
    Copy code
    js
    export const handle = (async ({ event, resolve }) => {
        const { session } = await getSupabase(event);
        const isAdmin = ['DEV', 'MANAGER', 'ADMIN'].includes(session?.user.app_metadata.userrole);
    
        if (event.url.pathname.startsWith('/admin') && !isAdmin) {
            // Unauthorized user is trying to access admin dashboard, redirect to login page
            throw redirect(307, '/account');
        } else if (event.url.pathname.startsWith('/account') &&
            isAdmin
        ) {
            // Admin is already logged in, redirect to admin dashboard
            throw redirect(307, '/admin');
        }
        return await resolve(event);
    }) satisfies Handle;
    This was working before but broke some time ago and I only noticed it yesterday.
    s
    t
    • 3
    • 17
  • storage - how do I search by filename or filepath?
    v

    Vince

    02/23/2023, 9:50 AM
    storage - how do I search by filename or filepath? I tried sorting but I couldn't find a specific file anywhere in the bucket
    g
    • 2
    • 3
  • Signups not allowed for otp ERROR version 2.8.0
    k

    kresimirgalic

    02/23/2023, 9:52 AM
    I am getting the error when running the code below
    Copy code
    const { data, error } = await supabase.auth.signInWithOtp({
        phone,
        options: {
          shouldCreateUser: false,
        },
      });
    Copy code
    code: 400
    msg: "Signups not allowed for otp"
    s
    g
    • 3
    • 2
  • Create function that adds calculated geo distance to items
    d

    davidf

    02/23/2023, 10:06 AM
    Hi, I'm building an app that contains a feed which can be filtered by different criteria, for example "all posts", "nearby", "created by me". So far, what I'm doing to fetch the posts is using the Javascript sdk so I do
    supabase.from('posts').select('')
    etc I have quite an elaborate query that fetches the author information, comments etc for each posts and does some filtering so my select is quite long. I'm struggling to get the
    nearby
    working. I have added the geolocation extension and all my posts store their location. I now have the users location and need to get posts based on a distance. I've written a function which already gets posts which gets posts within a specific view area, BUT where I'm struggling is how to combine that. I think from what I understand, I should be able to USE that function and then still use the SDK to do all my querying etc but I'm not quite sure how. Anyone able to help me out?
    s
    • 2
    • 19
  • Is there a way to set a longer timeout for an edgeless function?
    h

    Hugos

    02/23/2023, 10:11 AM
    I have a edgeless function that can take upto 10 seconds to finish its task, is there a way to set the timeout a bit longer just for that function, its generating an AI chess move
  • Redirect to reset-password component
    d

    DevThoughts

    02/23/2023, 10:15 AM
    when the user clicks on the Supabase email reset-password link, i want to redirect user to password reset component at http://localhost:54321/reset-password. How do i modify url?
    s
    • 2
    • 4
  • User access control
    b

    byod

    02/23/2023, 10:23 AM
    Hello there, I'm new to devlopment, and want to ask the following: - i created a table which consists of basic todo colums such as title, status etc. - I want to know when i fetch the todo data in my app, how can i only fetch the data of the user that is currently logged in should i have to make a column in the table that is linked to auth table? - i am new so any resource for learning this kind of basic things will be very much helpful to me. I'm using flutter for my app.
    a
    • 2
    • 4
1...142143144...230Latest