Out new collection with sequence numeric id after stages in mongodb aggregate

db.collection.aggregate([
   {
      $setWindowFields: {
         sortBy: { _id: 1, },
         output: { _id: { $documentNumber: {} } }
      }
   }
])
Topics: MongoDB

Related Code Examples