Update Repeater contents after database change - refresh()?

Option 3 works

Inside the onReady function of my dataset I am updating the information based on another dataset. This is successful.

From this my Repeater should be updated with the new entries but nothing happens. Only on page reload does it show the new items.

I have tried the following based on various other posts I have found:

export function dataset1_ready() {
    wixData.bulkInsert("database", dataToInsert);
    .then( (results) => {
        $w("#dataset1").refresh();    //Option 3
    } )
    
    //Option 1:
    $w("#dataset1").refresh();
    
    //Option 2:
    $w("#repeater").forEachItem( ($item, itemData, index) => {
        $item("#dataset1").refresh();
    });
}

What I would like to know is why does Option 3 work and not 1?
As it is there is a few seconds delay before the Repeater gets updated.

Hi CP, one reason why option 3 works is because you are using a promise chain (the part that looks like .then( (results) => {code}) ) This means that the dataset will only refresh after the data is inserted in “database”, and not too early like in option 1.