MongoDB: group by created_at and sender
Message Collection Structure

<pre><code>Message = new Schema
    type:           String
    body:           Schema.Types.Mixed
    sender:         { type: String, enum: ['machine', 'profile'], default: 'machine' }
    created_at:     { type: Date, default: Date.now }
    updated_at:     { type: Date, default: Date.now }
</code></pre>

<p>Query</p>

<pre><code>&gt; db.messages.find({},{created_at: 1, sender: 1, _id: 0})
</code></pre>

<p>Returns</p>

<pre><code>{ "created_at" : ISODate("2016-08-20T08:31:59.890Z"), "sender" : "profile" }
{ "created_at" : ISODate("2016-08-20T08:32:00.256Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-20T08:32:24.908Z"), "sender" : "profile" }
{ "created_at" : ISODate("2016-08-19T08:32:24.960Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-19T08:33:36.456Z"), "sender" : "profile" }
{ "created_at" : ISODate("2016-08-19T08:33:36.551Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-19T08:50:19.331Z"), "sender" : "profile" }
{ "created_at" : ISODate("2016-08-19T08:50:19.643Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-19T08:50:29.638Z"), "sender" : "profile" }
{ "created_at" : ISODate("2016-08-18T08:50:30.326Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-18T08:50:40.996Z"), "sender" : "profile" }
{ "created_at" : ISODate("2016-08-17T08:50:42.431Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-17T08:50:48.606Z"), "sender" : "profile" }
{ "created_at" : ISODate("2016-08-17T08:50:49.709Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-17T08:50:51.163Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-16T08:51:26.154Z"), "sender" : "profile" }
{ "created_at" : ISODate("2016-08-16T08:51:26.186Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-16T08:51:26.714Z"), "sender" : "machine" }
{ "created_at" : ISODate("2016-08-15T08:53:36.383Z"), "sender" : "profile" }
{ "created_at" : ISODate("2016-08-15T08:53:37.798Z"), "sender" : "machine" }
</code></pre>

<p>I need help with a query that will return responses grouped by date and sender.</p>

<p>For example: On date = 2016-08-15 AND sender = profile, count = 2</p>

<p>An array:</p>

<pre><code>profile: [{ 2016-08-12: 10}, { 2016-08-13: 10} , { 2016-08-14: 5}]

machine: [{ 2016-08-12: 10}, { 2016-08-13: 10} , { 2016-08-14: 5}]
</code></pre>

<p>Need help with drafting it in a Mongo friendly format</p>