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