How to change a type of a array using runCommand

Hi @Matheus_Souza and welcome in the MongoDB Community :muscle: !

I would do an aggregation pipeline like this. Maybe there is a more simple solution but… I like it :wink: !

[
  {
    '$project': {
      'orders': {
        '$map': {
          'input': '$orders', 
          'in': {
            '_id': '$$this'
          }
        }
      }
    }
  }, {
    '$merge': {
      'into': 'coll', 
      'on': '_id', 
      'whenMatched': 'merge', 
      'whenNotMatched': 'fail'
    }
  }
]

I tested on a couple of docs and I have the correct result in the end. I’m basically overwriting the orders field.

Cheers,
Maxime.