Database

db={"col1":[{code:1,name:"data1"},{code:2,name:"data2"}],"col2":[{code:1,type:"type1"},{code:1,type:"type2"},{code:2,type:"type2"}]}

Query

db.col1.aggregate([{"$lookup":{"from":"col2","localField":"code","foreignField":"code","as":"type"}},{$addFields:{type:"$type.type"}}])

Result