exclude fields in $lookup aggregation

Solution 1:

In mongodb 3.6 you can use projection ($project) inside $lookup pipeline... Something like this

db.User.aggregate([
  { "$match": { "userID":"1" }},
  { "$lookup":{
    "from": "Skill",
    "pipeline": [
      { "$match": { "languageID": "hindiid", "skillID": { "$in": [ "javaid","pythonid" ] }}},
      { "$project": { "_id": 0 }}
    ],
    "as": "skills"
  }}
])