Database

[{sessionId:1,checkoutAmount:100,orderStatus:1,productInfo:[{productId:1,quantity:10,price:1000,totalAmount:10000}]}]

Query

db.collection.aggregate([{$match:{sessionId:1,"productInfo.productId":1}},{$set:{checkoutAmount:{$add:["$checkoutAmount",{$reduce:{input:"$productInfo",initialValue:0,in:{$cond:[{$eq:["$$this.productId",1]},"$$this.totalAmount","$$value"]}}}]},productInfo:{$filter:{input:"$productInfo",cond:{$ne:["$$this.productId",1]}}}}}])

Result