I have a collection with the gallery field that has multiple images in reach row of the collection.
While adding data to the collection I mistakenly used the Gallery Description instead of Gallery Title property.
Of course, I can update the Titles with the Descriptions one by one but that would take too long time.
Trying to figure out the code to do that. Does anybody have a sample to accomplish something similar?
So far I got this
wixData.query(“myCollection”)
.find()
.then( (results) => {
let res = results.items;
let count = results.length;
for (var i = 0; i < count; i++)
{
let currentItem = res[i];
let cntPic = currentItem.galleryFld.length;
let pics = currentItem.galleryFld;
for (var k = 0; k < cntPic; k++)
{
pics[k].title = pics[k].description;
pics[k].description = "";
}
//everything works fine to this point but not Update
//how to assign new Gallery Properties to the current row and save changes?
currentItem.galleryFld.items = pics;
wixData.update(“myCollection”, currentItem);
}
} );