Proper way to createUrls from multiple rows

I have a table with different kinds of carousel item (image, text, text2)
Under the data column, the image typed data has a
path
key where the image is stored in Storage

I have the follownig code:
const { data: items, error: items_error } = await db.from('carousel_items').select('id, type, author, duration, visible, data').in('id', data.items);


I know that i can do the following to filter the image items and createUrls(), however i'm not sure how it can properly be appended to the data key back at the items level

const imageItems = items.filter(item => item.type === 'image');

type DBImageData = {
    title: string;
    path: string;
};

const imageItemUrls = imageItems.map(item => (item.data as DBImageData).path);


I want the data to be returned as
{
  title: 'title',
  url: 'createdUrl'
}


If someone could help with a 'workflow' that would be great! Thanks in advance!
Was this page helpful?