How to duplicate items with different id in repeaters

I have a repeater with id, ‘#pattern98repeatr’. It has a dataset row from a database which looks like
$w(‘#pattern98repeatr’).data = {
“photo”: “wix:image://v1/616b1f_db31691e6e4c479cb18c0ed9b4bf4254~mv2.png/98023.png#originWidth=793&originHeight=175”,
“_id”: “b793dbc3-0b94-465b-88a9-a914a2ab4449”,
“_owner”: “616b1fdd-2651-4380-9dd8-d41e9e7ec7ca”,
“_createdDate”: “Mon May 16 2022 18:41:40 GMT-0700 (Pacific Daylight Time)”,
“_updatedDate”: “Mon May 30 2022 12:40:42 GMT-0700 (Pacific Daylight Time)”,
“mouldLength”: “244”,
“title”: “98023”,
“link-panelmoulding-98-title”: “/panelmoulding-98/98023”
}
Now, i want to create the exact copy of this with a different “_id” in a different variable and concat that to the original repeater.
How to do that?
Thanks in advance!!

You can use a for-loop, or a for-each-loop, or maybe you can map through given data, replacing each item’s ID, or what ever you want.

In the same time you also could use the same loop, to create separated data, generating/populating new ARRAYs.

let myNewDataArray = []

This one inside loop…
myNewDataAreay.push(…)

The easiest way would be something like this:

$w.onReady(() => {
  // Repeater data has to be an array
  let repeaterData = [
    {
      photo:
        'wix:image://v1/616b1f_db31691e6e4c479cb18c0ed9b4bf4254~mv2.png/98023.png#originWidth=793&originHeight=175',
      _id: 'b793dbc3-0b94-465b-88a9-a914a2ab4449',
      _owner: '616b1fdd-2651-4380-9dd8-d41e9e7ec7ca',
      _createdDate: 'Mon May 16 2022 18:41:40 GMT-0700 (Pacific Daylight Time)',
      _updatedDate: 'Mon May 30 2022 12:40:42 GMT-0700 (Pacific Daylight Time)',
      mouldLength: '244',
      title: '98023',
      'link-panelmoulding-98-title': '/panelmoulding-98/98023',
    },
  ]
  const newItem = { ...repeaterData[0], _id: 'new-id' } //Copy the first item of the array and change the id

  $w('#pattern98repeatr').data = [...repeaterData, newItem] //Add the new item to the repeater
})

Thank you so much…

Thank you so much…