Clear a dataset of current users inputs?

I have been trying to clear a dataset of the currently logged in user inputs into a dataset by using ‘onClick’ to trigger the deletions. On the page the dataset has been filtered by logged in user, and displays their inputs in a table correctly. I tried using an ‘onClick’ event to trigger a ‘bulkRemove’, but apparently I do not understand the ‘itemIDs’ argument in the function. Then I tried using this link & example, but this didn’t help out either :

It deleted all the rows even though I embedded it in a query for just the current user.

Any suggestions?

If your dataset if filtered and you want to delete only the filtered items you need to first get all those items and extract their IDs (_id) inside an array.

Something like this:

import wixData from 'wix-data';

var array = [];

export function dataset1_ready() {
   let count = $w("#dataset1").getTotalCount();
   $w("#dataset1").getItems(0, count)
   .then((res) => {
      let items = res.items;
      items.forEach((item) => {
         array.push(item._id);
      });
   });
}
export function button1_click(event) {
   wixData.bulkRemove("customers", array)
   .then( (results) => {
      console.log(results);
   })
   .catch( (err) => {
      console.log(err);
   });
}

Make sure that you have the correct permissions setup on your collection.

Ah! I do believe you have pointed out the errors in my thought process! I’ll give it another go today and let you know. Thank you!

Funny how doing things correctly, and at the proper time, makes things work!
Thanks again!