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