Database

db={"products":[{productCode:"xxx",price:299},{productCode:"yyy",price:15},],"basket":[{"hash":"xxxxx","items":[{productCode:"xxx",qty:4},{productCode:"yyy",qty:2}]}]}

Query

db.basket.aggregate([{$limit:1},{$unwind:"$items"},{$lookup:{from:"products",localField:"items.productCode",foreignField:"productCode",as:"products"}},{$unwind:"$products"},{$group:{_id:"$_id",items:{$push:"$items"},products:{$push:"$products"},totalCost:{$sum:{"$multiply":["$products.price","$items.qty"]}}}},{$project:{_id:false,}}])

Result