change root mongodb code example Example: mongodb replace root db.collection.aggregate([ { $replaceRoot: { newRoot: "$name" } }])