DELETE all rows in a data collection??

I have read many of the posts on here from last year about the capability of DELETing all rows in a collection and I have tried many of the solutions listed on here such as this one:

export function button26_click(event) {
 //Add your code for this event here: 
    $w('#text69').text = "Starting";
    wixData.query("MEMBERS")
        .limit(1000)
        .find()
        .then((result) => {
 for (var i = 0; i < result.items.length; i++) {
 if (result.items[i] === null) continue;
                $w('#text69').text = String(i);
                wixData.remove("MEMBERS", result.items[i]._id);
            }
            $w('#text69').text = "Delete's have been made";
        });
}

However, I have found all of these work arounds to be inconsistant. Sometimes they will delete a few hundred rows and then when executed again it will remove even fewer rows that the time before.

You have had several months to add the capability to clear a data collection of all data and still I do not see a solution. How hard can this be!! It’s a simple query. Place a link or button on the content manager page that will clear the data collection.

Is someone working on this???

1 Like

If you are wanting to completely clear a dataset collection, you might as well just delete the dataset yourself!

And do what then? Recreate it each time? I am working with test data that I need to clear often as I test my code. If I had to recreate the structure each time it would just add more time for me, shen all that is needed is a way to clear all rows. On most database engines it’s a simplw one line SQL Query.

Right now the only way to clear the collection is to iterate over them one at a time and that has proven to be inconsistant with the number of rows it deletes. Sometimes it will delete a few hundred, other times it will only delete a hundred or so at a time.

There’s just gotta be a cleaner, more efficent way to do this.

This is infuriating that it’s not available. I have 200 items I want to get rid of and the only way to do it is one by one.

James, since this thread was posted last year the truncate function was introduced.