https://supabase.com/ logo
Join Discord
Powered by
# off-topic
  • m

    Marky

    08/11/2021, 1:34 AM
    Does upsert() support composite keys? It doesn't seem the table editor does
    s
    • 2
    • 2
  • u

    __ianjasper

    08/11/2021, 2:06 AM
    Im wondering if how will I use auth.uid() to ensure that the post or comment that one being created/inserted is the actual id of the user and not of the other?
  • s

    Scott P

    08/11/2021, 2:07 AM
    RLS policy on insert:
    (uid() = user_id)
    (if
    user_id
    is the name of the column where the user ID is stored)
  • u

    __ianjasper

    08/11/2021, 2:09 AM
    I have another question. Can i omit passing the userId on the DTO but use the auth.uid to insert the post along side with other details of the post?
  • s

    Scott P

    08/11/2021, 2:15 AM
    You should be able to do it with a postgres
    BEFORE INSERT
    trigger. The function that's triggered could do something like this:
    Copy code
    sql
    INSERT INTO public.some_table (column_1, is_public, user_id)
    VALUES ("Some string value", true, auth.uid());
  • s

    Scott P

    08/11/2021, 2:16 AM
    That's assuming that
    user_id
    isn't nullable. If it's allowed to be nullable, then an after insert trigger could do the same job
  • u

    __ianjasper

    08/11/2021, 2:17 AM
    Yes it isnt nullable :)
  • u

    __ianjasper

    08/11/2021, 2:17 AM
    What would u prefer off the two??
  • u

    __ianjasper

    08/11/2021, 2:18 AM
    Im honestly new to triggers and policies thats why πŸ˜…
  • s

    Scott P

    08/11/2021, 2:23 AM
    It depends on the use-case, but if I've got the option to insert it before, I'll take that route. You can also pass things like
    new.some_value
    as values, which are useful if the trigger is running on a `BEFORE INSERT`:
    Copy code
    sql
    CREATE OR REPLACE FUNCTION public.insert_article()
    RETURNS trigger
    LANGUAGE plpgsql
    SECURITY DEFINER AS $$
    begin
      INSERT INTO public.some_table
        (column_1, is_public, user_id, article_title, article_date)
      values
        ('some string value', true, auth.uid(), new.article_title, new.article_date);
      return new;
    end;
    $$;
    (That specific example might need some tweaking to work, but the general idea is there)
  • u

    __ianjasper

    08/11/2021, 2:31 AM
    Thanks @User πŸ™‚
  • x

    Xyo

    08/11/2021, 3:57 AM
    On that topic, I strongly suggest handling that kind of inserts/updates via your own backend
  • x

    Xyo

    08/11/2021, 3:58 AM
    I assume you would want some checks/sanitization which would be a pain to implement at pgsql level
  • x

    Xyo

    08/11/2021, 3:58 AM
    Unless it’s a simple text only post with not much going on
  • u

    __ianjasper

    08/11/2021, 4:22 AM
    I'll keep this in mind.. Yeah ur right. But right now as much as possible really im trying to make supabase a go to solution ignoring creating custom backend first.
  • u

    __ianjasper

    08/11/2021, 4:22 AM
    If i have a user that signed up via 3rd party provider..
  • u

    __ianjasper

    08/11/2021, 4:22 AM
    How can I link a password with that existing account?
  • x

    Xyo

    08/11/2021, 4:23 AM
    You just set the password with the Supabase SDK
  • x

    Xyo

    08/11/2021, 4:23 AM
    All accounts are linked by email by default iirc
  • x

    Xyo

    08/11/2021, 4:24 AM
    Same goes in reverse. If you create an email:password account, you can login with a third party provider if the account uses the same email
  • u

    __ianjasper

    08/11/2021, 4:26 AM
    Finally found it!!
    Copy code
    dart
    final userAttributes = UserAttributes(password: _password);
            final response =
                await Supabase.instance.client.auth.update(userAttributes);
    dang im looking
    Copy code
    dart
    Supabase.instance.client.auth.changePassword('');
  • t

    TheOriginalDude

    08/11/2021, 5:07 AM
    Same! I'm waiting for it too, Want to self host and use it.
  • b

    bim

    08/11/2021, 8:57 AM
    How do we go about upgrading postgres versions to the latest supported by supabase? Or must we create a new project, and migrate to the new project?
    s
    • 2
    • 1
  • s

    silentworks

    08/11/2021, 11:50 AM
    Upgrade Postgres to latest version
  • t

    ThisIsJustin

    08/11/2021, 3:14 PM
    What is the suggested way to duplicate a database for more than one environment? Say prod and dev. If we already have a built out prod DB how can I best keep a dev version in sync?
  • a

    Adamo

    08/11/2021, 4:03 PM
    What is the font supabase uses on the logo?
  • s

    Steve

    08/11/2021, 4:07 PM
    Upsert composite keys
  • f

    florian-lefebvre

    08/11/2021, 4:48 PM
    https://github.com/supabase/supabase/tree/master/www%2Fpublic%2Ffonts%2Fcustom
  • a

    Adamo

    08/11/2021, 4:49 PM
    thanks mate
  • e

    erik_flywheel

    08/11/2021, 6:54 PM
    can you trigger an api call from triggers+functions?
1...727374...392Latest