我只想从集合中提取当天的 MONGODB 数据。我试过这个要求:
db.hello.aggregate([
{ $match: { "name": "btb" } },
{ $where: function() {
today = new Date();
today.setHours(0,0,0,0);
return (this.date.getTimestamp() >= today)
}},
{ $group: {
_id: { articles: "$articles" },
total: { $sum: 1 }
}},
{ $project: {
"articles": 1,
"total": 1
}},
{ $sort: { "total":-1 } }
])
但我收到该消息错误:
####################################################################
Unable to execute the selected commands
Mongo Server error (MongoCommandException): Command failed with error 16436: 'Unrecognized pipeline stage name: '$where'' on server localhost:27017.
The full response is:
{
"ok" : 0.0,
"errmsg" : "Unrecognized pipeline stage name: '$where'",
"code" : NumberInt(16436)
}
####################################################################