bulkRemove all elements before bulkSave

Hi there!

I have a need to delete all elements in a collection with a bulkRemove method before adding new ones with a bulkSave.

Any idea on how this might be done?

I was trying to do something like this:
let newData=dataMapper(dataInJSON);
wixData.aggregate(“CollectionName”).then(currentData=>{
wixData.bulkRemove(“CollectionName”,currentData)).then(()=>{
wixData.bulkSave(“CollectionName”, newData);
})
I guess the aggregate method doesn’t work as I expected.
If I do just bulkSave it works but it just adds new elements (doesn’t delete the old ones)

Thanks!

@jmrferreira For your purposes, it would be simpler and easier to use the truncate function rather than bulkRemove.