How to include collection data on aggregation <p>I have the following MongoDB document structure:</p> <pre><code>user: { name: 'user name', email: 'email@gmail.com', isBlocked: false, cvs: [{ title: "role title", technologies: [ {name: 'JavaScript'} {name: 'NodeJs'} ], agents: [ { _id:'some id1', contactRequest: true }, { _id:'some id2', contactRequest: false } ], }] } </code></pre> <p>How can I add <code>user.name</code> to the output if I perform an aggregation with grouping on embedded document's property, e.g.</p> <pre><code>db.users.aggregate([ { "$match": { "cvs.isBlocked": false, "cvs.moderated": true, "cvs.isVisible": true, "cvs.technologies.main": true } }, {"$unwind": "$cvs"}, {"$unwind": "$cvs.technologies"}, { "$match": { "cvs.isBlocked": false, "cvs.moderated": true, "cvs.isVisible": true, "cvs.technologies.main": true } }, { "$group": { "_id": { "type": "$cvs.occupationType", "proficiency": "$cvs.proficiencyLevel", "_id": "$cvs._id", "title": "$cvs.title" }, "technologies": { "$push": "$cvs.technologies.text" } } }, { "$project": { "type": "$_id.type", "proficiency": "$_id.proficiency", "_id": "$_id._id", "title": "$_id.title", "technologies": 1, } } ]) </code></pre> <p>$$ROOT refers to $cvs in that case.</p> <p>Additionally I would like to include <code>user.name</code> and <code>email</code> only if <code>user.isBlocked</code> is <code>false</code> and <code>agent.contactRequest</code> is <code>true</code>.</p>