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