Good afternoon and apologies,
I’m using the update() api to let users update their user form.
Content is stored in a database named “EV owner Database”. Content (to be updated) in the database is “EV” and “Location”.
The code, from my limited understanding, should be ok. However, with each and every submit, a new line is written into the database. I added my understanding in the code notes. Could anyone give me some guidance which direction I should seek to fix that error? The code simply has no impact in my page.
import wixData from 'wix-data';
wixData.query("EVownerDatabase") //name of database
.eq("Owner", "00001") //owner submitted data??
.find() //if yes...
.then( (results) => { //then go to his results
if(results.items.length > 0) { //and if owner entered value
let item = results.items[0];
item.EV = "Tesla"; //update item, e.g. EV
item.Location ="Kiel";
wixData.update("EVownerDatabase", item);
} else {
// perform default, if owner not found (create new data)
}
} )
.catch( (err) => {
let errorMsg = err;
} );