PricingBlog

Delete rows in supabase

  • benajaephrath-1265924850963447831

    BenajaEphrath

    1 year ago

    I have followed a similar post but unfortunately I can't get any further. https://discord.com/channels/972416966683926538/1265353107752222720/1265353107752222720

    I have the following goal: From the tutorial https://youtu.be/SHJ3EadcrgY?si=o1xRI347kmt9VuE0 the possibility to delete individual Task-entries via a button.

    So this is what i have:
    1265924978227019888-image.png
  • 1265925056534413414-image.png
  • 1265925128827572254-image.png
  • 1265925213636530206-image.png
  • benajaephrath-1265925890882146396

    BenajaEphrath

    1 year ago

    I think I'm doing something wrong with the variable or with the click event. I am grateful for any tips. I understood the query, but as I said, nothing happens when I activate the delete button...
  • Tod-1265925892216062002

    Tod

    1 year ago

    Great energy @BenajaEphrath! Your continuous contribution to the toddle Community just made you advance to Community Level 3!
  • lucasg-1265926200711184444

    Lucas G

    1 year ago

    If you set RLS policies on the table, does it allow delete?
  • Though it's weird that there is no feedback from supabase on it
  • benajaephrath-1265926457272832010

    BenajaEphrath

    1 year ago

    Yes:
    1265926457016717332-image.png
  • lucasg-1265926616614309958

    Lucas G

    1 year ago

    Try setting the header
    Name: Prefer
    Value: return=representation
  • And see if you get any feedback
  • benajaephrath-1265926862144802899

    BenajaEphrath

    1 year ago

    Like this? Nothing happens
    1265926861884493886-image.png
  • lucasg-1265927073760018516

    Lucas G

    1 year ago

    RIght, you would see something when you make the call
  • benajaephrath-1265927108987981846

    BenajaEphrath

    1 year ago

    Nothing happens
  • benajaephrath-1265927388240543896

    BenajaEphrath

    1 year ago

    Lol this is weird. When i check the left check/uncheck button it deletes
  • Not sure if i can post here a screencast lets see...
  • lucasg-1265928765901504552

    Lucas G

    1 year ago

    It seems like it is actually deleting it but you might not be seeing it right away because the list is repeating straight from the API call instead of from a variable?
    🫣1
  • benajaephrath-1265928787934314566

    BenajaEphrath

    1 year ago

    So when i click the delete button nothing happens. But when i click first the delete button, and AFTER that the check/uncheck it gets deleted
  • lucasg-1265929967980511393

    Lucas G

    1 year ago

    Also I just realized that a return=representation wouldn't make sense on deletes lol 😅 early in the morning 😬
    😅1
  • benajaephrath-1267718649410617385

    BenajaEphrath

    1 year ago

    Hm, but my click event first fires the variable...
    1267718649201037354-image.png
  • max.kayr-1267732233905770496

    Max

    1 year ago

    It looks like in your list you are repeating directly over the results from the API. In this scenario, you need to refetch the list after the delete. So call the get data API again. Otherwise you delete it in the backend but you won't see the change in the frontend. I'm guessing that after the check you fetch the data again?
    😶1
  • benajaephrath-1267739425769652276

    BenajaEphrath

    1 year ago

    So now it works. 🔥🔥🍹👋 I set in my Click Event -> on success -> fetch the data

    Is this correct? Or is there an better way to do this?
    1267739425568460852-image.png
  • max.kayr-1267742179745468426

    Max

    1 year ago

    That is fine. It's a question of philosophy. You could also not repeat the list over the actual api result, but store the api result in a variable and repeat over that. Then you could update the variable (list of tasks) directly after success without refetching. Both versions work and are valid
  • benajaephrath-1267749213085630546

    BenajaEphrath

    1 year ago

    @Max thanks AGAIN! So helpful!!
    💪1