'MongoDB Transactions doing NodeJS migrations | UpdateMany/Aggregate to replace all documents fields

i'm trying to do NodeJS migrations and i'm a bit lost with mongodb transactions.

I have a db with 140 documents which are my users list and i want to change all fields structure.. I want to completely replace all actual documents with a new structure and new fields.

Well i already tested

coll.updateMany({}, {
  $set: {
    ...
  },
});

and

coll.aggregate([
  {
    $replaceWith: {
      ...
    },
  },
]);

Then migration is up in the console but there's no changes in the db, I don't know if i'm right and if i'm using good transactions.

I'm searching on MongoDB docs but it's not really clear for me

If anyone can help me understand this syntax it would be great



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source