trying to get a value of a field “total” in “total” collection
do calculation
and then update it back
(simple)
code:
wixData.query(‘total’).eq(‘kasar’,1).find()
.then(results =>{
if (results.items.length > 0) {
var tot = results.items[0];
console.log("total is " + tot.total );
let met = exChange*Number(amount)/3600;
let stam =Number(Math.round(met+‘e2’)+‘e-2’);
tot.total = tot.total + stam;
console.log("update total new value "+ tot.total);
debugger ;
wixData.update(“total”,tot)}})
wixData.query(‘total’).eq(‘kasar’,1).find()
.then(results =>{
if (results.items.length > 0) {
var tot1 = results.items[0];
console.log("total after update is " + tot1.total)}
debugger ;
console output shows no update was done
total is 44.24
update total new value 45.04
total after update is 44.24
and there is an error
“Uncaught (in promise)”
whats wrong?