【发布时间】:2019-11-01 02:29:34
【问题描述】:
我有一个这样设置的集合:
{
_id: uuid.v4(),
startDate: Date(),
}
我对此没有任何想法。我正在寻找的最终结果是这样的(total 是 日期内的用户数):
[
{
date: "2018-12",
total: 12
},
{
date: "2019-01",
total: 32
},
{
date: "2019-02",
total: 23
},
...
]
任何帮助将不胜感激。谢谢
【问题讨论】:
-
查看这些以获得一个想法:Aggregation group by date example 和 Aggregation date operators。
标签: mongodb aggregation-framework