title: Getting Mongo results from only previous month avg by default
body: <p>I have this data in mongodb:</p>
  
  <pre><code> [
  {
  
      "CreateDate" : ISODate("2018-08-08T04:53:51.840Z"),
      "cummulativeKWH" : 368.5,
       "frequency" : "50.12"
  },
  {
  
      "CreateDate" : ISODate("2018-08-08T04:53:51.840Z"),
      "cummulativeKWH" : 369.5,
       "frequency" : "50.12"
  },
  {
  
      "CreateDate" : ISODate("2018-09-03T04:53:51.840Z"),
      "cummulativeKWH" : 369.5,
       "frequency" : "50.12"
  },
  ]
  </code></pre>
  
  <p>I am new to MongoDb and would appreciate some help with this query. I wrote the following aggregation pipeline. I need to take the average of cummulativeKWH for that previous month only I am using filter methods and selected dates. How to get last previous month avg of cummulativeKWH (ex:aug 1-to-aug 31) only by default without selection and without filters.<br>
  Anyone please suggest me.</p>
  
  <pre><code> db.collection.aggregate([
    { "$match": {
      'createDate': {'$gte':ISODate("2018-08-01"), '$lte':ISODate("2018-08-31") } 
    }},
    {$group: {_id:null,
     cummulative: {$avg:"$cummulativeKWH"}
  }}
  ])
  </code></pre>
  
  <p>I am trying this aggregation I got the output but how to get without date selection and without filters how to get default previous  month avg of data.</p>