What you want is usage of the aggregation framework with the aggregate()
command, at least for finding one date as you ask:
SomeSchema.aggregate(
[
{ "$match": {
"date": {
"$gte": new Date("2014-05-08"), "$lt": new Date("2014-05-09")
}
}},
{ "$group": {
"_id": "$some_item",
"count": { "$sum": 1 }
}}
],
function(err,result) {
// do something with result
}
);
If you are specifically looking for "counts" over several dates then you can do something like this:
SomeSchema.aggregate(
[
{ "$match": {
"date": {
"$gte": new Date("2014-05-01"), "$lt": new Date("2014-06-01")
}
}},
{ "$group": {
"_id": {
"year": { "$year": "$date" },
"month": { "$month": "$date" },
"day": { "$dayOfMonth": "$date" }
}
"count": { "$sum": 1 }
}}
],
function(err,result) {
// do something with result
}
);
And that gives you "per day" grouping. Look for the date aggregation operators in the documentation if you wish to take this further.