我只想从当天的集合中提取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)
}
####################################################################
https://stackoverflow.com/questions/51536823
复制相似问题