Database

db={"invoices":[{_id:"123",client:"ABC"}],"payments":[{_id:"456",invoiceId:"123",amount:100},{_id:"789",invoiceId:"123",amount:50}]}

Query

db.invoices.aggregate([{$lookup:{from:"payments",localField:"_id",foreignField:"invoiceId",as:"payments"}},{$addFields:{amount:{$sum:"$payments.amount"}}},{$project:{payments:0}}])

Result