How to delete an entire data collection from a particular database as there is no Select All option?

It is really cumbersome to select each row and delete and then import the fresh data since the freshly imported data do not get overwritten as well and keeps on getting appended to old data rather.

The sales reports I need to update every month change and are imported via .csv file. I am unable to flush out the old data at one shot by a Select All function and then import fresh. Kindly help or provide a solution as this is becoming really tedious.

What I usually do is select the number at the side and drag it to the bottom. Example if the data inputted is from 1 to 30 i will select them all and then right click, select "Delete’.

And there is another way to it. Try the below because I don’t think there is a feature available yet to delete the whole database. You can adjust the limit depending on the query.

function clear() {
    wixData.query("yourCollection")
    .limit(1000)
    .find()
    .then((results) => {
      removeItems(results.items);
        console.log(removeItems);
});
}

async function removeItems(items) {
 await items.forEach(async (item, i) => {
                $w('#text1').text = String(i);
 await wixData.remove("yourCollection", items[i]._id);
    });
}

Thank you for the reply. Yes that ways it can be done for the Sandbox database but not the live on.

Again if I do that for Sandbox and use Sync with Live, the live database remains as it is and does not get overwritten.

@ukiyotopublishing I’m really sorry I don’t think it works like that. If I’m not mistaken the live data can only be edited manually. It is a missing feature from Wix which I hope they implement as soon as possible.

But anyways try to use the below, I’m not sure it will work or not but you should give a try first :

$w("#dataset1").onReady(async() => {
	if ($w("#dataset1").getCurrentItem()) {
		await $w("#dataset1").remove();
		while ($w("#dataset1").hasNext()) {
			await $w("#dataset1").next();
			await $w("#dataset1").remove();
		}
	}
});