title: How to run this MongoDB query using MongoEngine
body: <p>I can't tell if MongoEngine supports the aggregate framework.</p>
  
  <p>Is it possible to run this query using MongoEngine?</p>
  
  <pre><code>db.collection.aggregate([
      { "$group": {
          "_id": {
              "year": { "$year": "$utc_timestamp" },
              "month": { "$month": "$utc_timestamp" },
              "day": { "$dayOfMonth": "$utc_timestamp" },
          },
          "defects": {
              "$sum": { "$cond": [
                  { "$eq": [ "$status", "defect" ] },
                  1,
                  0
              ]}
          },
          "totalCount": { "$sum": 1 }
      }},
      { "$project": {
          "defect_rate": {
              "$cond": [
                  { "$eq": [ "$defects", 0 ] },
                  0,
                  { "$divide": [ "$defects", "$totalCount" ] }
              ]
          }
      }}
  ])
  </code></pre>
  
  <p>If not, can I just run it directly (raw) through MongoEngine?</p>