'how to get the another collection data whose id is stored in array

I am having a collection like this whose users ids are stored inside the array,I need to query the collection A to get collection B whose "_id" (only "_id") is stored in array type , how to get in mongodb using aggregate ?

collection A :

{
  "_id" : ObjectId("5ccfc2d176013e48a4ec0eed"),
  "position" : ObjectId("5c73bcd0697b545c329a4bd4"),
  "users" : [ 
   "5bbf3cc7381e7a6530872089"
   ],
    
   "inCase" : [],
   "completed" : false,
    
}

am having second collection as

Collection B

{
  "_id" : ObjectId("5b517a2bebb3b14b4cd78ca9"),
  "firstName" : "Katie",
  "lastName" : "Carter",
  "languages" : [ 
        "English", 
        "", 
        ""
    ],
}

My code

{$lookup:{from:'user',localField:'users',foreignField:'_id',as:'users'}},
        {$unwind:'$users'},

let me know how to resolve it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source