Deleting Multiple Records based on a condition

Options
I am new to Xano.  Is there a way to delete multiple records based on a condition?  For example, I have in my database set of dates in UnixTimeFormat and I wanted to delete all records lesser than the current Unix Time.

I was thinking also of creating stack of functions like :
1.  Query All records that satisfy the condition then
2. Delete all the results from number 1. 

Is this possible?

Thanks. 

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Yup! You just need to loop through the results of your query

    
  • artrab
    artrab Member
    Options
    I watched the video and just a wow, that was easy to implement.  Thanks  !
  • Xanoguy
    Xanoguy Member
    Options

    Argh. It's not intuitive that the delete record function only deletes one at a time. When I delete record where item.feature_id = input, I expect to delete all matching records with feature_id equal to the input. I believe based on a few hours of troubleshooting (can you confirm) that delete record would only delete the first such match.

  • Alimama
    Alimama Member
    edited July 2023
    Options

    https://docs.xano.com/guides/data-manipulation/deleting-data/deleting-multiple-records

    @Xanoguy it should delete all rows in your item table's where column feature_id matches input. I don't know if you have seen the above video by @Michael Udinski. It should provide some clarity even though it uses a list input (list of product IDs) in this case.

  • Xanoguy
    Xanoguy Member
    Options

    Thanks Alimama. I did watch that video, and since Michael used a For-Next loop (again) in that video, it was one of the reasons I concluded you couldn't delete multiple records with the one delete function.