Database

db={"Employee":[{"_id":"kcXtyaB7jGPw9Ks","name":"Test name","post":"Manager","departmentId":"xQQrzRgi8","dateCreated":"2022-07-12T13:09:16.270Z","dateModified":"2022-07-12T13:09:16.270Z"},{"_id":"mNkyaB6jGPw7KB","name":"Test2 name","post":"Manager","departmentId":"56sgAeKfx","dateCreated":"2022-07-12T13:09:16.270Z","dateModified":"2022-07-12T13:09:16.270Z"}],"Department":[{"_id":"xQQrzRgi8","departmentName":"Testing department"},{"_id":"56sgAeKfx","departmentName":"HR department"}]}

Query

db.Employee.aggregate([{$lookup:{from:"Department",localField:"departmentId",foreignField:"_id",as:"departmentName",},},{$set:{departmentName:{$first:"$departmentName.departmentName"},},},{$project:{departmentId:0},},])

Result