Best way t o store such data as user name, profile pic, etc.

  • ssssadsadasd-1360987618501853224

    ssssadsadasd

    15 days ago

    During a user section I want to save such data as user name, user profile picture, username etc so that I do not make an extra call everytime.
    I am using supabase, and I initially thought saving these in the supabase user_metadata would be the best solution but this is not reccommeded apparently. so I was wondering what is an alternative solution?
    save to local/session storage does not seem a good option? will the "save to cache" feature that will be coming to toddle fit to this case? thanks
  • lucasg-1360988600229040221

    Lucas G

    15 days ago

    Just create a users table
  • ssssadsadasd-1360996727393357925

    ssssadsadasd

    15 days ago

    @Lucas G not sure what you mean with "users" table. in supabase, you have the authentication users which contains the email and some other basic user data. I extended this with a "profile" table. however, this is the point of my question: I need some data almost always and I do not want to call the profile table everytime (besides the user call that i do make everytime)
  • lucasg-1361008628164985042

    Lucas G

    15 days ago

    There isn’t really a workaround other than calling the profile table
  • lucasg-1361010170783600910

    Lucas G

    15 days ago

    The only alternative is the auth table’s metadata, but then if you ever need to implement multi-tenancy then you wouldn’t be able to call that data from another user’s view as that data is only available to the logged in user.
  • That and a few other restrictions means it’s just easier to use the profile table
  • ssssadsadasd-1361248147862454315

    ssssadsadasd

    14 days ago

    I initially added the data to the user_metadata but it produced all kind of edge cases and it was not reccomended even in the supabase discord.
  • ssssadsadasd-1361248452809330709

    ssssadsadasd

    14 days ago

    @Lucas G so am not sure what is the standard here? e.g. if I will need such data as profile_image, name, username in a sidebar in a dashboard at all times do I have to make the call every time? can I somehow save that data in the cache and when the session ends the data is automaticall removeD?
  • lucasg-1361357364078444615

    Lucas G

    14 days ago

    The standard is to store it in a table, like your profile table.
  • lucasg-1361358893263093974

    Lucas G

    14 days ago

    You can use browser storage alongside it but you'll have to put a few checks in place if you want to do that.
    First is that browser storage is not permanent so you'll have to check if it exists then fetch if not, since this is done client-side you'll want to implement placeholders as the content will never be there on initial load.
    You'll also have to implement 'stale' checks and update the data whenever it is changed in the database.
    Since a user could login and update the data from another device, you'll have to add that to the checks on load
  • lucasg-1361359360290328697

    Lucas G

    14 days ago

    If you're just using small sessions then stale data isn't as big of an issue compared to just trying to always using whatever is in local storage
  • lucasg-1361360083061051705

    Lucas G

    14 days ago

    Sometimes users upload different images but with the same name too so when you're doing storage checks, you'll want to check by update date too not just file name.
    Basically give the data an 'expiry' to check and refresh