exclude fields in $lookup aggregation

前端 未结 1 1438
有刺的猬
有刺的猬 2020-11-27 08:29

I am querying between 3 collections I want to exclude _id everywhere in output

My output is:

{
    \"_id\" : ObjectId(\         


        
相关标签:
1条回答
  • 2020-11-27 09:22

    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"
      }}
    ])
    
    0 讨论(0)
提交回复
热议问题