Deleting Multiple Records


I had a look through your video on creating a todo app.

Now that I have a bunch of records, I’d like to delete the ones marked as “done”. How can this be achieved? I have created a “Delete Done Tasks” button and I’m trying to utilize the “Delete Record” logic.

I have troubles deleting even a single record without hardcoding the ID as I’m not sure how to find the correct ID corresponding to the task name. What would happen if there are multiple tasks with the same name?

Thanks for you assistance upfront!

For deleting one record, I got around by using “tap component” on the list and storing that as a data variable. Then I click the “Delete Done Tasks” button and it works. Not the prettiest way of doing it but at least something.

How could I still achieve deleting multiple records?

I’m probably using a different database (Firestore), but the basic principle is that you would create a logic loop. You have a couple of format options, but since reads in Firestore are insanely cheap, I would do it this way:

  1. Get All Records (tasks)
  2. Set a data variable equal to the subset marked “done” (use SELECT function)
  3. If the data variable’s list length is 0, then you’ve deleted all the “done” tasks, so you can move on (end loop). Otherwise:
  4. Set a page variable equal to the ID of the first item in the data variable.
  5. Delete, using the ID you’ve set. Loop back to…
  6. Get All Records (tasks)
1 Like

If you want to minimize calls to the database, you can also just do a single Get All Records, and create an “increment” variable that you will set equal to the number of items in the data variable (list) that you created in Step 2. Then at the end of each loop you subtract one from the “increment” variable, and Step 1 in the loops is just to check whether the increment variable = 0, in which case, end the loop.

1 Like