Response:
If you want to update multiple objects ie 200 than java script is not the best way to do it.
you can use free marker API to update objects.
I am sharing you a sample Free marker script to update all the objects in the collection and add an new property "id", in all the objects in the collection. here I have assume, previously "id" property not exist in object, so it will add this property in every object. if this property exist in your objects, you can give it another name, it will work as a unique id for each object.
<#assign data = list_objects({"$query":{},"$orderby":{"name":-1}},"testColl")>
<#assign counter = 0>
<#assign items = []>
<#list data as i>
<#assign counter = counter + 1>
<#assign myObject=P_json_accumulate( i, "id", counter)>
<#assign items = items + [myObject]>
</#list>
<#assign array1 = save_object(items,"testColl")>
${array1}
Note:- here "testColl" is the name of the collection.
If you want to do it in java script, then one way to achieve this,
load all the objects of the collection in java script, modify each object using the for loop, and update it back in for loop.
if your pattern is giving you multiple record, add more property in the search criteria to give you 1 object, if you are not able to get a single object by adding more property in search pattern, it means you have duplicate objects with same data, you need to remove duplicate objects to normalize your collection.