MongoDB array sum query

How can I get all the sum of fields in an array in mongoose? From the db i want to sum up all the amounts in payments array. DB: { "_id" : 0, "name" : "shoe", "payments" : [ { "type" : "a", "amount" : 10 }, { "type" : "b", "amount" : 15 },… Read More MongoDB array sum query