Hi, I need simple thing, but I don’t find direct function in Velo to do this:
I want to change specific cell in one row, keeping the rest of data in this row:
One row for one user _id. If the user is new, I would put in new row for him.
Ive tried save() for new user, but this funkcion seems to create another row every time.
Ive tried update(), but console.log doesn’t report anything.
Preview doesn’t show any problems. There are no changes in collection; it totaly doesn’t work when I try like this:
setInterval(function(){ //////////////////it works out of $w.onReady, but setInterval should be called at the end anyway
while ($w("#audioPlayer1").isPlaying===true) {
let ctime = $w("#audioPlayer1").currentTime; //<----I take data from player, while it's playing
wixData.query("AudioCT")
.eq("_id", thisuser)
.find()
.then( (res) => {
if(res.items.length > 0) {
items = res.items;
rest1p1 = items[0].t1p1;
rest1p2 = items[0].t1p2;
let track = {
"_id": thisuser,
"t1p1": ctime,
"t1p2": rest1p2
}
wixData.update("AudioCT", track)
.then( (results) => {
let checkon = results;
console.log("Update:"+checkon);
} )
.catch( (err) => {
let errorMsg = err;
} );
} else { //<--------------when the user is new
let track = {
"_id": thisuser,
"t1p1": ctime
}
wixData.save("AudioCT", track)
.then( (results) => {
let checkon = results;
console.log("Update:"+checkon); // <----nothing in console
} )
.catch( (err) => {
let errorMsg = err;
} );
}
})
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
}
},3000);
My code looks realy heavy. I don’t believe there is no simple way to place the value simply in correct cell.