2
I created the database and fill in a 'stock' collection as in the attached figure.
I was trying to make the sum of the quantity of items in the stock, but Mongo only returns me the value 0 (zero). I used the following command:
db.estoque.Aggregate({$group:{_id:null, sum:{$sum:'quantity'}}})
What I’m doing wrong?
Put a "$" before the amount. {$sum:'$quantity'}
– Leonardo Buta