Database
db={"patient":[{_id:ObjectId("5f469bd60ca1a76de048ef47"),patientIllness:[],userID:"5f3ac77ae5fd03695c7f34e7",firstName:"rahul",lastName:"sharma",photo:"https://picsum.photos/200/300",age:51,gender:"male",addressLine1:"Jamuna Paar",adressLine2:"East Delhi",city:"New Delhi",pinCode:"500078",__v:0}],"user":[{_id:ObjectId("5f3ac77ae5fd03695c7f34e7"),active:"active",email:"adishrtv10@gmail.com",phone:"7748973500",__v:0}]}
Query
db.user.aggregate([{$match:{_id:ObjectId("5f3ac77ae5fd03695c7f34e7")}},{$lookup:{from:"patient",as:"patient_details",let:{id:"$_id"},pipeline:[{$match:{$expr:{$eq:[{$toObjectId:"$userID"},"$$id"]}}}]}},{$unwind:{path:"$patient_details",preserveNullAndEmptyArrays:true}}])