V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐工具
RoboMongo
推荐书目
50 Tips and Tricks for MongoDB Developers
Related Blogs
Snail in a Turtleneck
devqin
V2EX  ›  MongoDB

mongodb 聚合查询,返回今天,昨天,本周,上周,本月,上月的聚合能一次返回么?

  •  
  •   devqin · 2016-12-27 16:58:12 +08:00 · 5074 次点击
    这是一个创建于 2648 天前的主题,其中的信息可能已经有所发展或是发生改变。

    { "_id" : "aBAj43ZZKFLyRucx33", "name" : "李三", "createAt" : ISODate("2016-12-16T10:31:37.501Z") }

    如上的记录,如何返回根据 createAt 字段返回今天,昨天,本周,上周,本月,上月用户注册的聚合吗?

    参考: https://docs.mongodb.com/manual/reference/operator/aggregation/

    2 条回复    2016-12-27 18:16:34 +08:00
    gdsagdada
        1
    gdsagdada  
       2016-12-27 17:47:53 +08:00
    出门左转 stackoverflow ,问前先搜
    a342191555
        2
    a342191555  
       2016-12-27 18:16:34 +08:00
    project:
    "today" : {"$push" : ...}
    "yesterday" : {"$push" : ...}
    .......
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3210 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:33 · PVG 19:33 · LAX 04:33 · JFK 07:33
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.