First of all, I am formatting the date from the database from its standard "Thu 31st May 2019 Arabian Standard Time GMT +0430....." to a more readable format such as "Thu, 12st December"
Now, I am putting this inside a onReady function and telling the page to update the new date format into the database.
the problem is only the 1st row gets updated, how should I create a loop to update all dates
let user = wixUsers.currentUser;
let userId = user.id;
$w("#dataset1").onReady( () => {
$w("#repeater1").forEachItem( ($w) => {
const originalDate = $w("#date").text;
const newDate = originalDate.split(' ').splice(0, 4).join(' ');
$w('#date').text = newDate;
wixData.query("Cart")
.eq("userId", userId)
.find()
.then((results) => {
let items = results.items;
items.forEach((item) => {
let values = results.items[0];
let dateUpdate = newDate;
values.pickDate = dateUpdate;
wixData.update("Cart", values);
});
});
});
})
})
I tried the above but it doesn't work
![](https://static.wixstatic.com/media/a27d24_facca5d07fbb44cb9d521e87f4edf55f~mv2.png/v1/fill/w_980,h_175,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/a27d24_facca5d07fbb44cb9d521e87f4edf55f~mv2.png)
Same answer as the other thread, don't update using the values, you must use the item you are looping through,