首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >mongodb系统当前日期(yyyy-mm-dd)

mongodb系统当前日期(yyyy-mm-dd)
EN

Stack Overflow用户
提问于 2018-07-26 18:37:41
回答 2查看 1.9K关注 0票数 1

我只想从当天的集合中提取MONGODB中的数据。我尝试了这个请求:

代码语言:javascript
复制
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 } }
]) 

但是我得到了错误的消息:

代码语言:javascript
复制
####################################################################

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)
}

####################################################################
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51536823

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档