Answers for "while $vlookup how can we convert local field to objectId"

0

while $vlookup how can we convert local field to objectId

db.role.aggregate([
  { "$lookup": {
    "let": { "userObjId": { "$toObjectId": "$userId" } },
    "from": "user",
    "pipeline": [
      { "$match": { "$expr": { "$eq": [ "$_id", "$$userObjId" ] } } }
    ],
    "as": "userDetails"
  }}
])
Posted by: Guest on October-26-2021

Code answers related to "while $vlookup how can we convert local field to objectId"

Browse Popular Code Answers by Language