我试图获取某些日期分组的某些项目的计数。 这使用以下聚合查询:
// the query below does not work as soon as date matching is added
// this query always return 0 documents
[
{'$match': {
'some_id': ObjectId('foobar'),
'some_boolean_value': true,
'some_date':
{
'$gte': '2015-08-01T00:00:00.000Z',
'$lte': '2015-08-31T23:59:59.999Z'
}
}
},
{'$project':
{'day':
{'$substr': ['$some_date', 0, 10]}}
},
{'$group': {_id: '$day', count: { '$sum': 1 }}},
{'$sort': {_id: -1}}
]
下一步是我想使用此查询,但有日期限制。 我希望计算每天分组的日期限制。
.Range[_xlWorksheet.Cells[1, 1], _xlWorksheet.Cells[10, 10]]