The change that is in the new document is the _id field is replaced by a complex _id object (productId : String, country : String)
The country field is to be completed for the entire collection with a specific value - DE.
The collection has about 40 million records in the old format and 700k in the new format. I would like to bring these 40 million to this new form. I’m using mongo 3.6, so I’m a bit limited and I’ll probably have to use the aggregate functions to create a completely new collection, and then remove the old one. I will be grateful for help on how to do it - how the query that will do it should look like and how to keep these migrated 700k documents.
$match is not needed here. $project is also not needed unless you are changing the shape.
this will process all documents, old and new, and replaces all old “_id” fields, so try on a test collection first as you might have parts we are not aware of.