Suppose I have collection with following data.
{
_id: ObjectID(....),
...
data : [ 23, 34]
}
I have following JavaScript function.
function reduce(array){
//some computation
return result; // not array
}
Is there any way to update all the collection using MongoDB shell with following net effect.
{
data : reduce(data)
}
Edit:
I am looking to execute this for only one time as part of migration.