Good day,
I want to perform a query and update a field for every single item in the results. My code is not working though. What am I missing?
wixData.query(“articles”)
.eq(“_owner”, owner)
.find()
.then((results) => {
let theRecord = results.items;
theRecord.name = ${name} ${last}
;
wixData.save(“articles”, theRecord);
});
Nevermind, I found the solution
$w.onReady(function () {
wixData.query("myCollection")
.find()
.then((results) => {
let items = results.items;
items.forEach((element, index) => {
let toUpdate = { //write down all the item's feilds(_id, title,...)
"_id": element._id,
"title": element.title,
"score": "score" // add the new score here
};
wixData.update("myCollection", toUpdate);
});
});
});