{
{
"date": "2017-09-04",
"description": "DD from my employer1",
"amount": 1000.33
},
{
"date": "2017-09-06",
"description": "DD from my employer1",
"amount": 1000.34
},
{
"date": "2017-09-06",
"description": "DD from my employer1",
"amount": 1000.35
},
{
"date": "2017-09-07",
"description": "DD from employer1",
"amount": 5000.00
},
{
"date": "2017-09-08",
"description": "DD from my employer1",
"amount": 2000.33
},
{
"date": "2017-09-09",
"description": "DD from my employer1",
"amount": 2000.33
},
{
"date": "2017-09-10",
"description": "DD from my employer1",
"amount": 2000.33
}
}
I have this set of objects above, and I am trying to count the amount of unique dates. There are 7 objects with date field but as you can see 2017-09-06 shows up twice so that means that there are only a total count of 6 days. I am trying to group my date but can't get mongo to count only the dates once and treat the ones that show up more than once as just one.
I have tried this...
{
{
"$group": {
"_id": {
"description": "$description",
"date": "$date"
},
"count": {
"$sum": 1
}
}
}
}