Aggregation merge with Batchsize

How to use aggregation merge with BatchSize

I have tried using the following code in Node.Js

let pipeline = [
        {
            $match: {
              "data.batchcode":"0DEt0r3Xzrb2SSw50FGhJ36aG5h8RLY95sdhntWl"
            }
          },
        {
          $merge: {
            into: "test"
          }
        }
      ];
       await collection.aggregate(pipeline).batchSize(500).forEach(function (aRow) {
        console.log(doc);
       }) 
1 Like