Solved - Updating DB works in PREVIEW but not LIVE (no hooks)

Hi,
I was trying things out and noticed Updating the database doesn’t work in LIVE mode and I can’t find the ERROR message in console (Chrome - DevTools).
Note: Everything updates perfectly in PREVIEW mode including the uploading of images.

Example of results in PREVIEW:

//wixData.update
{...}
_id: "040ab321-494d-4864-9347-f22939b04caf"
title: "1080 Snowboarding"
developer: "Nintendo"
publisher: "Nintendo"
year: 1998
rating: "wix:image://v1/c8261d_c59270a61b28498498337dae327073e3~mv2.png/perfect.png#originWidth=154&originHeight=34"
cover: "wix:image://v1/c8261d_f9eb42eb9bac4f009fafcb2c3baf5353~mv2.jpg/1080%20Snowboarding%20(USA).jpg#originWidth=340&originHeight=248"
regions: "JP, NA, PAL"
category: 1
_owner: "c8261d0c-8152-4b03-8e89-ed1498fd18bb"
_createdDate: "2020-08-04T14:48:28.894Z"
_updatedDate: "2020-08-21T15:55:01.246Z"
link-znintendo64-title: "/gliden64/1080-snowboarding"

//wixData.insert
{...}  
title: "1080 Snowboarding"
version: "1.4"
comments: "<p>test4</p>"
rating: "wix:image://v1/c8261d_c59270a61b28498498337dae327073e3~mv2.png/perfect.png#originWidth=154&originHeight=34"
gallery: [...]
cdate: "August 21, 2020"
_id: "c5c5d5b6-89d7-4bec-b3d2-a711314691d4"
_owner: "c8261d0c-8152-4b03-8e89-ed1498fd18bb"
_createdDate: "2020-08-21T15:55:01.339Z"
_updatedDate: "2020-08-21T15:55:01.339Z"


The Code for Updating database

import wixData from "wix-data";
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';

export function submitButton_click(event, $w) {
	if($w("#idBox").value.length > 2) {
		var date = new Date();
		const options = {
    			day: "numeric",
    			month: "long",
    			year: "numeric"
		};
		
		let toInsert = {
		"title": $w('#gameTitle').value,
		"version": $w('#verBox').value,
		"comments": $w('#richTextBox').value,
		"rating": $w('#gameStatus').value,
		"gallery": $w("#gallery").items,
		"cdate": date.toLocaleDateString("en-US", options).toString()
		};
		wixData.insert("xxxxxx", toInsert)
  			.then( (results) => {
    			let item = results; //see item below
				console.log(item)
  			})
  			.catch( (err) => {
    			let errorMsg = err;
				$w('#textFailure').show();
 			});

		let toUpdate = {
		"_id": $w('#idBox').value,
		"title": $w('#gameTitle').value,
		"developer": $w('#devBox').value,
		"publisher": $w('#pubBox').value,
		"year": Number($w('#yearBox').value),
		"rating": $w('#gameStatus').value,
		"cover": $w('#coverBox').value,
		"regions": $w('#regiBox').value,
		"category": Number($w("#categBox").value)
		};
		wixData.update("xxxxx", toUpdate)
		  	.then( (results) => {
    				let item = results; //see item below
				console.log(item)
  			})
			.catch( (err) => {
				let errorMsg = err;
				$w('#textFailure').show();
			});
   			$w('#textsuccess').show();
		
		wixWindow.lightbox.close();
		setTimeout(() => {wixLocation.to(wixLocation.url)}, 4000)
	}	
	else {
		$w('#textFailure').show()
	}	
}

I’m testing LIVE on Chrome.
If you wanna try, you can access the updater by going to “https://www.emunations.com/gliden64-compatibility” and clicking on the red update button and a LightBox will appear.
From there, input game name “1080 snowboard” and random details stuff and press submit…

Any help would really be appreciated!
I thought PREVIEW / LIVE wouldn’t have these kind of issues arise :frowning:

-checked permissions of your database?
-synced your data with live ?

1 Like

Wow, it was my permissions after all​:sweat_smile::sweat_smile::sweat_smile:
Thx for your help :slight_smile:

Yes of course :grin: as assumed.
When everything works in PREVIEW-MODE, it should also working in LIVE.

In the most of situations, it is always the permissions or the missed sync between LIVE and PREVIEW.

Duly noted :stuck_out_tongue:

Do not forget to like it if you really liked it (or even a best answer?).