I’m using an array field in my database and trying to update to add a component to the array whenever the submit service button is pressed. It seems like the .update isn’t working because despite “done” appearing in the console, nothing has changed in the database when I look at it afterward. Thanks for any help!
export function btnSubmitNewService_click(event) {
//Add your code for this event here:
let id = $w("#dynamicDataset").getCurrentItem()._id;
let address = $w('#txtAddress').text;
console.log(address);
let date = $w('#dtDateOfService').value;
console.log(date);
let notes = $w('#inpNotesOnVisit').value;
console.log(notes);
let firstService = new Service();
firstService.Address = address;
firstService.Date = date;
firstService.Notes = notes;
wixData.query("dtbsAddresses").eq("_id", id).find()
.then((results) => {
if (results.length > 0) {
let allServices = [];
allServices.concat(results.items[0].gdServices);
allServices.push(firstService);
let toUpdate = {
"_id": id,
"gdServices": allServices
};
console.log(toUpdate);
wixData.update("dbtsAddresses", toUpdate);
$w('#inpNotesOnVisit').value = "";
$w('#dtDateOfService').value = new Date();
console.log("done");
}
})
.catch((err) => {
let errorMsg = err;
console.log(err);
});
}
The error that appears:
WDE0025: The dbtsAddresses collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor.