Update to Sandbox DB works but not Live DB

I am using wix code API to update the value in the database.
I am using modules / server-side to make the actual updates.
The code works properly when I am in Preview mode, it updates the Sandbox DB. But when I publish the site and go to the published page, the update to live DB doesn’t happen even though call to the backend module function seems to happen.

private.jsw

export function updateDownloadCount(itemId) {
let options = {
“suppressAuth”: true
};
var items;
let collectionName = “Downloadables”;
wixData.get(collectionName, itemId, options)
.then((results) => {
let item = results;
item[“downloadCount”] = (results[“downloadCount”] || 0) + 1;
return wixData.update(collectionName, item)
.then((updateResults) => {
let item2 = updateResults;
console.log("update results ", item2);
})
.catch((err) => {
let errorMsg = err;
});
})
.catch((err) => {
let errorMsg = err;
return errorMsg
});
return true;
}

frontend

export function button2_click(event, $w) {
updateDownloadCount(event.context.itemId).then(function(result) {
console.log(“result”, result);
})
.catch(error => {
console.log(“error is”, error);
});
}

Hey
In your frontend page you must import the function / module updateDownloadCount form the private.jsw module file. Have you done that?

If you have done that I would guess it is a permission thing, you execute an update on a dataset and you might need to set the permission on the data collection to allow updates by others than admins then.

Thanks for the tip Andreas.

That was it, the permission on the Database collection was not as expected!