mongoose - Query $sum of range of values in mongodb -


so have following mongodb collection called expenses.

description |   date    | value | parking lot  2017-02-22    10 mcdonalds    2017-03-01    50 burgerking   2017-03-12    100 parking lot  2017-03-21    15 

i want query range of dates, 2017-03-01 2017-03-31 and sum of value field.

db.expenses.aggregate([ {$match:{"date":{$gte:isodate("2017-03-01t00:00:00z"),                  $lte:isodate("2017-03-31t00:00:00z")}}}, {$group:{_id:null, sumvalue:{$sum:"$value"}}} ]); 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -