Good morning Wix Community,
I have a database which is fed by a repeater input element.
Since I need to have the repeater feeding Database empty when using it next time, I want to move all this data into a second, permanent, database with the same fields with an button_onClick event.
My code so far:
export function buttonMoveToPerm_click(event) {
moveToPerm()
}
function moveToPerm () {
let toInsert = $w("#tempProductsDataset").getItems();
//also tried = wixData.query("TempProducts");
wixData.bulkInsert("PermProducts", [toInsert])
.then( (results) => {
let inserted = results.inserted;
console.log(results.inserted, "results inserted")
let insertedIds = results.insertedItemIds;
console.log(results.insertedItemIds, "inserted IDs")
let updated = results.updated;
let skipped = results.skipped;
let errors = results.errors;
console.log(results.errors, "errors")
} )
.catch( (err) => {
let errorMsg = err;
} );
}
The code is only creating one new empty item in the PermProducts database.
Console log shows:
1 results inserted
Array(1) inserted IDs
0: "55825274-f748-431f-ac53-98a6821ee335"
Array(0) errors
I have no coding experience, but with the Corvid Reference documentation I’ve been pretty good so far. This one is driving me nuts.
Can someone point out my mistakes?
Or suggest a better solution?
Thanks in advance!