Database

[{"username":"John","shopping_cart":{"coffee":2,"chocolate":3,"icecreem":2}}]

Query

db.collection.aggregate([{$addFields:{shopping_cart_sum:{$reduce:{input:{$objectToArray:"$shopping_cart"},initialValue:0,in:{$add:["$$this.v","$$value"]}}}}}])

Result